Skip to content

Commit 5deda0c

Browse files
author
Alan Christie
committed
refactor: Further reafctoring (launcher params etc.)
1 parent 4711816 commit 5deda0c

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

tests/instance_launcher.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ def launch(self, launch_parameters: LaunchParameters) -> LaunchResult:
126126
self._msg_dispatcher.send(pod_message)
127127

128128
return LaunchResult(
129-
# The errors returned here are the launch errors, not the Job's errors.
130-
error=0,
131-
error_msg=None,
132129
instance_id=instance_id,
133130
task_id=task_id,
134131
command=" ".join(subprocess_cmd),

tests/test_test_instance_launcher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_launch_nop(basic_launcher):
4444
project_id=TEST_PROJECT_ID,
4545
application_id=DM_JOB_APPLICATION_ID,
4646
name="Test Instance",
47-
launch_username="dlister",
47+
launching_user_name="dlister",
4848
running_workflow_id=rwfid,
4949
running_workflow_step_id=rwfsid,
5050
specification={"collection": "workflow-engine-unit-test-jobs", "job": "nop"},
@@ -55,7 +55,7 @@ def test_launch_nop(basic_launcher):
5555
result = launcher.launch(lp)
5656

5757
# Assert
58-
assert result.error == 0
58+
assert result.error_num == 0
5959
assert result.command.startswith("python ")
6060
assert result.command.endswith("tests/jobs/nop.py")
6161

@@ -80,7 +80,7 @@ def test_launch_nop_fail(basic_launcher):
8080
project_id=TEST_PROJECT_ID,
8181
application_id=DM_JOB_APPLICATION_ID,
8282
name="Test Instance",
83-
launch_username="dlister",
83+
launching_user_name="dlister",
8484
running_workflow_id=rwfid,
8585
running_workflow_step_id=rwfsid,
8686
specification={
@@ -94,7 +94,7 @@ def test_launch_nop_fail(basic_launcher):
9494
result = launcher.launch(lp)
9595

9696
# Assert
97-
assert result.error == 0
97+
assert result.error_num == 0
9898
assert result.command.startswith("python ")
9999
assert result.command.endswith("tests/jobs/nop-fail.py")
100100

@@ -119,7 +119,7 @@ def test_launch_smiles_to_file(basic_launcher):
119119
project_id=TEST_PROJECT_ID,
120120
application_id=DM_JOB_APPLICATION_ID,
121121
name="Test Instance",
122-
launch_username="dlister",
122+
launching_user_name="dlister",
123123
running_workflow_id=rwfid,
124124
running_workflow_step_id=rwfsid,
125125
specification={
@@ -133,7 +133,7 @@ def test_launch_smiles_to_file(basic_launcher):
133133
result = launcher.launch(lp)
134134

135135
# Assert
136-
assert result.error == 0
136+
assert result.error_num == 0
137137
assert result.command.startswith("python ")
138138
assert result.command.endswith(
139139
"tests/jobs/smiles-to-file.py --smiles C1=CC=CC=C1 --output output.smi"

workflow/workflow_abc.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LaunchParameters:
1616
project_id: str
1717
application_id: str
1818
name: str
19-
launch_username: str
19+
launching_user_name: str
2020
specification: dict[str, Any]
2121
specification_variables: dict[str, Any] | None = None
2222
debug: bool | None = None
@@ -30,9 +30,10 @@ class LaunchParameters:
3030

3131
@dataclass
3232
class LaunchResult:
33-
"""Results returned from methods in the InstanceLauncher."""
33+
"""Results returned from methods in the InstanceLauncher.
34+
Any error returned in this object is a launch error, not a Job error."""
3435

35-
error: int
36+
error_num: int = 0
3637
error_msg: str | None = None
3738
instance_id: str | None = None
3839
task_id: str | None = None

workflow/workflow_engine.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
107107
assert "running_workflow" in response
108108
running_workflow = response["running_workflow"]
109109
assert "user_id" in running_workflow
110-
launch_username: str = running_workflow["user_id"]
110+
launching_user_name: str = running_workflow["user_id"]
111111
_LOGGER.debug("RunningWorkflow: %s", running_workflow)
112112
# Now get the workflow definition (to get all the steps)
113113
wfid = running_workflow["workflow"]["id"]
@@ -138,16 +138,16 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
138138
project_id=project_id,
139139
application_id=DM_JOB_APPLICATION_ID,
140140
name=first_step_name,
141-
launch_username=launch_username,
141+
launching_user_name=launching_user_name,
142142
specification=json.loads(first_step["specification"]),
143143
specification_variables=variables,
144144
running_workflow_id=r_wfid,
145145
running_workflow_step_id=r_wfsid,
146146
)
147147
lr: LaunchResult = self._instance_launcher.launch(lp)
148-
if lr.error:
148+
if lr.error_num:
149149
self._set_step_error(
150-
first_step_name, r_wfid, r_wfsid, lr.error, lr.error_msg
150+
first_step_name, r_wfid, r_wfsid, lr.error_num, lr.error_msg
151151
)
152152
else:
153153
_LOGGER.info(
@@ -245,20 +245,20 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
245245
project_id=project_id,
246246
application_id=DM_JOB_APPLICATION_ID,
247247
name=next_step_name,
248-
launch_username=running_workflow["user_id"],
248+
launching_user_name=running_workflow["user_id"],
249249
specification=json.loads(next_step["specification"]),
250250
specification_variables=variables,
251251
running_workflow_id=r_wfid,
252252
running_workflow_step_id=r_wfsid,
253253
)
254254
lr = self._instance_launcher.launch(lp)
255255
# Handle a launch error?
256-
if lr.error:
256+
if lr.error_num:
257257
self._set_step_error(
258258
next_step_name,
259259
r_wfid,
260260
r_wfsid,
261-
lr.error,
261+
lr.error_num,
262262
lr.error_msg,
263263
)
264264
else:

0 commit comments

Comments
 (0)