@@ -243,6 +243,36 @@ def get_running_workflow_steps(self, *, running_workflow_id: str) -> dict[str, A
243
243
steps .append (item )
244
244
return {"count" : len (steps ), "running_workflow_steps" : steps }
245
245
246
+ def get_instance (self , * , instance_id : str ) -> dict [str , Any ]:
247
+ UnitTestWorkflowAPIAdapter .lock .acquire ()
248
+ with open (_INSTANCE_PICKLE_FILE , "rb" ) as pickle_file :
249
+ instances = Unpickler (pickle_file ).load ()
250
+ UnitTestWorkflowAPIAdapter .lock .release ()
251
+
252
+ return {} if instance_id not in instances else instances [instance_id ]
253
+
254
+ def get_task (self , * , task_id : str ) -> dict [str , Any ]:
255
+ UnitTestWorkflowAPIAdapter .lock .acquire ()
256
+ with open (_TASK_PICKLE_FILE , "rb" ) as pickle_file :
257
+ tasks = Unpickler (pickle_file ).load ()
258
+ UnitTestWorkflowAPIAdapter .lock .release ()
259
+
260
+ return {} if task_id not in tasks else tasks [task_id ]
261
+
262
+ def get_job (self , * , collection : str , job : str , version : str ) -> dict [str , Any ]:
263
+ assert collection == _JOB_DEFINITIONS ["collection" ]
264
+ assert job in _JOB_DEFINITIONS ["jobs" ]
265
+ assert version
266
+
267
+ jd = _JOB_DEFINITIONS ["jobs" ][job ]
268
+ response = {"command" : jd ["command" ]}
269
+ if "variables" in jd :
270
+ response ["variables" ] = jd ["variables" ]
271
+ return response
272
+
273
+ # Methods required for the UnitTestInstanceLauncher
274
+ # but not exposed to (or required by) the Workflow Engine...
275
+
246
276
def create_instance (self , * , running_workflow_step_id : str ) -> dict [str , Any ]:
247
277
UnitTestWorkflowAPIAdapter .lock .acquire ()
248
278
with open (_INSTANCE_PICKLE_FILE , "rb" ) as pickle_file :
@@ -261,15 +291,7 @@ def create_instance(self, *, running_workflow_step_id: str) -> dict[str, Any]:
261
291
262
292
return {"id" : instance_id }
263
293
264
- def get_instance (self , * , instance_id : str ) -> dict [str , Any ]:
265
- UnitTestWorkflowAPIAdapter .lock .acquire ()
266
- with open (_INSTANCE_PICKLE_FILE , "rb" ) as pickle_file :
267
- instances = Unpickler (pickle_file ).load ()
268
- UnitTestWorkflowAPIAdapter .lock .release ()
269
-
270
- return {} if instance_id not in instances else instances [instance_id ]
271
-
272
- def create_task (self , * , instance_id : str ) -> dict [str , Any ]:
294
+ def create_task (self ) -> dict [str , Any ]:
273
295
UnitTestWorkflowAPIAdapter .lock .acquire ()
274
296
with open (_TASK_PICKLE_FILE , "rb" ) as pickle_file :
275
297
tasks = Unpickler (pickle_file ).load ()
@@ -287,22 +309,3 @@ def create_task(self, *, instance_id: str) -> dict[str, Any]:
287
309
UnitTestWorkflowAPIAdapter .lock .release ()
288
310
289
311
return {"id" : task_id }
290
-
291
- def get_task (self , * , task_id : str ) -> dict [str , Any ]:
292
- UnitTestWorkflowAPIAdapter .lock .acquire ()
293
- with open (_TASK_PICKLE_FILE , "rb" ) as pickle_file :
294
- tasks = Unpickler (pickle_file ).load ()
295
- UnitTestWorkflowAPIAdapter .lock .release ()
296
-
297
- return {} if task_id not in tasks else tasks [task_id ]
298
-
299
- def get_job (self , * , collection : str , job : str , version : str ) -> dict [str , Any ]:
300
- assert collection == _JOB_DEFINITIONS ["collection" ]
301
- assert job in _JOB_DEFINITIONS ["jobs" ]
302
- assert version
303
-
304
- jd = _JOB_DEFINITIONS ["jobs" ][job ]
305
- response = {"command" : jd ["command" ]}
306
- if "variables" in jd :
307
- response ["variables" ] = jd ["variables" ]
308
- return response
0 commit comments