Skip to content

Commit 3443bcb

Browse files
author
Alan Christie
committed
feat: Alteration to InstanceLauncher and launch params
1 parent f6c2ef5 commit 3443bcb

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

workflow/workflow_abc.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,49 @@ class LaunchParameters:
1515
The launching user API token is the second element when the request header's
1616
'Authorization' value is split on white-space."""
1717

18-
application_id: str
18+
# The Project UUID to launch the instance in
1919
project_id: str
20+
# A symbolic name of the Instance
2021
name: str
22+
# The user name of the person launching the Instance/Workflow
2123
launching_user_name: str
24+
# The API Access token provided by the User
2225
launching_user_api_token: str
26+
# The specification, which can contain 'variables'
2327
specification: dict[str, Any]
28+
# An alternative way to passing variables to the specification.
29+
# If used it will replace any 'variables' key in the specification.
2430
specification_variables: dict[str, Any] | None = None
25-
debug: bool | None = None
26-
callback_url: str | None = None
27-
callback_token: str | None = None
28-
callback_context: str | None = None
29-
generate_callback_token: bool | None = None
31+
# A string. In DM v4 converted to a boolean and set in the
32+
# instance Pod as a label.
33+
debug: str | None = None
34+
# The RunningWorkflow UUID
3035
running_workflow_id: str | None = None
36+
# The RunningWorkflowStep UUID
3137
running_workflow_step_id: str | None = None
38+
# The application ID (a custom resource name)
39+
# used to identify the 'type' of Instance to create.
40+
# For DM Jobs this will be 'datamanagerjobs.squonk.it'
41+
application_id: str = "datamanagerjobs.squonk.it"
3242

3343

3444
@dataclass
3545
class LaunchResult:
3646
"""Results returned from methods in the InstanceLauncher.
3747
Any error returned in this object is a launch error, not a Job error."""
3848

49+
# A numeric non-zero error code if an error occurred
50+
# and an optional message
3951
error_num: int = 0
4052
error_msg: str | None = None
53+
# The Instance UUID that was created for you
4154
instance_id: str | None = None
55+
# The Task UUID that is handling the Instance launch
4256
task_id: str | None = None
43-
callback_token: str | None = None
57+
# The rendered command used in the instance
4458
command: str | None = None
59+
# A callback token (unused in Workflows)
60+
callback_token: str | None = None
4561

4662

4763
class InstanceLauncher(ABC):
@@ -51,7 +67,9 @@ class InstanceLauncher(ABC):
5167
@abstractmethod
5268
def launch(
5369
self,
70+
*,
5471
launch_parameters: LaunchParameters,
72+
**kwargs: str,
5573
) -> LaunchResult:
5674
"""Launch a (Job) Instance"""
5775

workflow/workflow_engine.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
_LOGGER.setLevel(logging.INFO)
4343
_LOGGER.addHandler(logging.StreamHandler(sys.stdout))
4444

45-
# The 'well known' application ID for Jobs
46-
DM_JOB_APPLICATION_ID: str = "datamanagerjobs.squonk.it"
47-
4845

4946
class WorkflowEngine:
5047
"""The workflow engine."""
@@ -155,7 +152,6 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
155152

156153
lp: LaunchParameters = LaunchParameters(
157154
project_id=project_id,
158-
application_id=DM_JOB_APPLICATION_ID,
159155
name=first_step_name,
160156
launching_user_name=launching_user_name,
161157
launching_user_api_token=rwf_response["running_user_api_token"],
@@ -164,7 +160,7 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
164160
running_workflow_id=r_wfid,
165161
running_workflow_step_id=r_wfsid,
166162
)
167-
lr: LaunchResult = self._instance_launcher.launch(lp)
163+
lr: LaunchResult = self._instance_launcher.launch(launch_parameters=lp)
168164
if lr.error_num:
169165
self._set_step_error(
170166
first_step_name, r_wfid, r_wfsid, lr.error_num, lr.error_msg
@@ -286,7 +282,6 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
286282
variables: dict[str, Any] | None = rwf_response.get("variables")
287283
lp: LaunchParameters = LaunchParameters(
288284
project_id=project_id,
289-
application_id=DM_JOB_APPLICATION_ID,
290285
name=next_step_name,
291286
launching_user_name=rwf_response["running_user"],
292287
launching_user_api_token=rwf_response["running_user_api_token"],
@@ -295,7 +290,7 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
295290
running_workflow_id=r_wfid,
296291
running_workflow_step_id=new_r_wfsid,
297292
)
298-
lr = self._instance_launcher.launch(lp)
293+
lr = self._instance_launcher.launch(launch_parameters=lp)
299294
# Handle a launch error?
300295
if lr.error_num:
301296
self._set_step_error(

0 commit comments

Comments
 (0)