Skip to content

Commit a041983

Browse files
feature: add tc are suggestions in exec (#206)
Summary: - add time constraints are suggestions flag - add no redirect flag for direct scle frontend node address ``` $ transcriptic preview Seal | transcriptic exec --api localhost:9000 --no-redirect -w wc0-mcx1 Sending request to localhost:9000 Success. View localhost:9000/dashboard to see the scheduling outcome. $ transcriptic preview Seal | transcriptic exec --api localhost:9000 --no-redirect -w wc0-mcx1 -tc-suggestion Sending request to localhost:9000 Success. View localhost:9000/dashboard to see the scheduling outcome. $ transcriptic preview Seal | transcriptic exec --api localhost:9000 -w wc0-mcx1 -tc-suggestion Invalid api target, expects http://base/facility/workcell. ```
1 parent 06c21b6 commit a041983

2 files changed

Lines changed: 56 additions & 29 deletions

File tree

transcriptic/cli.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,14 @@ def format_cmd(manifest):
635635
@click.option(
636636
"--api",
637637
"-a",
638-
help="The api endpoint of your scle test workcell instance.",
638+
help="The api endpoint of your test dashboard, or the scle test workcell instance (if used with --no-redirect).",
639639
required=True,
640640
)
641+
@click.option(
642+
"--no-redirect",
643+
help="If set, the api endpoint given is the scle test workcell instance.",
644+
is_flag=True,
645+
)
641646
@click.option(
642647
"--workcell-id",
643648
"-w",
@@ -672,6 +677,12 @@ def format_cmd(manifest):
672677
default=None,
673678
help="Delay in minutes at which the given protocol should start (at the earliest).",
674679
)
680+
@click.option(
681+
"--time-constraints-are-suggestion",
682+
"-tc-suggestion",
683+
help="If set, the time constraints will be considered only a suggestion.",
684+
is_flag=True,
685+
)
675686
@click.option(
676687
"--partition-group-size",
677688
type=click.INT,
@@ -692,12 +703,14 @@ def format_cmd(manifest):
692703
def execute(
693704
autoprotocol,
694705
api,
706+
no_redirect,
695707
workcell_id,
696708
device_set,
697709
session_id,
698710
time_limit,
699711
schedule_at,
700712
schedule_delay,
713+
time_constraints_are_suggestion,
701714
partition_group_size,
702715
partition_horizon,
703716
partitioning_swap_device_id,
@@ -706,12 +719,14 @@ def execute(
706719
commands.execute(
707720
autoprotocol,
708721
api,
722+
no_redirect,
709723
workcell_id,
710724
device_set,
711725
session_id,
712726
time_limit,
713727
schedule_at,
714728
schedule_delay,
729+
time_constraints_are_suggestion,
715730
partition_group_size,
716731
partition_horizon,
717732
partitioning_swap_device_id,

transcriptic/commands.py

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,12 +1479,14 @@ def run_protocol(api, manifest, protocol, inputs, view=False, dye_test=False):
14791479
def execute(
14801480
autoprotocol,
14811481
api,
1482+
no_redirect,
14821483
workcell_id,
14831484
device_set,
14841485
session_id,
14851486
time_limit,
14861487
schedule_at,
14871488
schedule_delay,
1489+
time_constraints_are_suggestion,
14881490
partition_group_size,
14891491
partition_horizon,
14901492
partitioning_swap_device_id,
@@ -1500,19 +1502,6 @@ def execute(
15001502
if clean_api[-1] == "/":
15011503
clean_api = clean_api[0:-1] # remove trailing slash
15021504

1503-
# Validate api
1504-
path_tokens = clean_api.split("/")
1505-
if len(path_tokens) != 3:
1506-
click.echo(
1507-
f"Invalid api target, expects http://base/facility/workcell.", err=True
1508-
)
1509-
return
1510-
1511-
clean_api = f"http://{clean_api}"
1512-
path_base = f"http://{path_tokens[0]}"
1513-
path_lab = path_tokens[1]
1514-
path_workcell = path_tokens[2]
1515-
15161505
# Define the initial payload
15171506
payload = {"timeLimit": f"{time_limit}:second"}
15181507

@@ -1577,25 +1566,48 @@ def execute(
15771566
if partitioning_swap_device_id is not None:
15781567
payload["partitioningSwapDeviceId"] = partitioning_swap_device_id
15791568

1580-
res = requests.get(f"{path_base}/app-config")
1581-
try:
1582-
res_json = json.loads(res.text)
1583-
if (
1584-
res_json["hostManifest"]
1585-
and res_json["hostManifest"][path_lab]
1586-
and res_json["hostManifest"][path_lab][path_workcell]
1587-
):
1588-
frontend_node_address = res_json["hostManifest"][path_lab][path_workcell]
1589-
else:
1590-
click.echo(f"Error when get frontend node address: {res_json}", err=True)
1569+
payload["timeConstraintsAreSuggestion"] = time_constraints_are_suggestion
1570+
1571+
if no_redirect:
1572+
frontend_node_address = clean_api
1573+
else:
1574+
# Validate api
1575+
path_tokens = clean_api.split("/")
1576+
if len(path_tokens) != 3:
1577+
click.echo(
1578+
f"Invalid api target, expects base-url/facility/workcell.", err=True
1579+
)
1580+
return
1581+
1582+
clean_api = f"http://{clean_api}"
1583+
path_base = f"http://{path_tokens[0]}"
1584+
path_lab = path_tokens[1]
1585+
path_workcell = path_tokens[2]
1586+
1587+
# get the scle test workcell endpoint
1588+
res = requests.get(f"{path_base}/app-config")
1589+
try:
1590+
res_json = json.loads(res.text)
1591+
if (
1592+
res_json["hostManifest"]
1593+
and res_json["hostManifest"][path_lab]
1594+
and res_json["hostManifest"][path_lab][path_workcell]
1595+
):
1596+
frontend_node_address = res_json["hostManifest"][path_lab][
1597+
path_workcell
1598+
]
1599+
else:
1600+
click.echo(
1601+
f"Error when get frontend node address: {res_json}", err=True
1602+
)
1603+
return
1604+
except json.decoder.JSONDecodeError:
1605+
click.echo(f"Error when get frontend node address: {res.text}", err=True)
15911606
return
1592-
except json.decoder.JSONDecodeError:
1593-
click.echo(f"Error when get frontend node address: {res.text}", err=True)
1594-
return
15951607

15961608
# POST to workcell
15971609
test_run_endpoint = f"http://{frontend_node_address}/testRun"
1598-
click.echo(f"Sending request to {frontend_node_address}")
1610+
click.echo(f"Sending request to http://{frontend_node_address}")
15991611
res = requests.post(test_run_endpoint, json=payload)
16001612
try:
16011613
res_json = json.loads(res.text)

0 commit comments

Comments
 (0)