Skip to content

Commit 96fc51e

Browse files
author
Alan Christie
committed
fix: Better structure, and launcher now returns the command
1 parent 2d2ef56 commit 96fc51e

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

tests/instance_launcher.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99

1010
_JOB_DIRECTORY: str = os.path.join(os.path.dirname(__file__), "jobs")
1111

12-
_SUCCESS_LAUNCH_RESULT: LaunchResult = LaunchResult(
13-
error=0,
14-
error_msg=None,
15-
instance_id="instance-00000000-0000-0000-0000-000000000000",
16-
task_id="task-00000000-0000-0000-0000-000000000000",
17-
)
18-
1912

2013
class UnitTestInstanceLauncher(InstanceLauncher):
2114
"""A unit test instance launcher, which runs the
@@ -47,4 +40,10 @@ def launch(
4740
completed_process: CompletedProcess = subprocess.run(job_cmd, check=True)
4841
assert completed_process.returncode == 0
4942

50-
return _SUCCESS_LAUNCH_RESULT
43+
return LaunchResult(
44+
error=0,
45+
error_msg=None,
46+
instance_id="instance-00000000-0000-0000-0000-000000000000",
47+
task_id="task-00000000-0000-0000-0000-000000000000",
48+
command=" ".join(job_cmd),
49+
)

tests/test_test_instance_launcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ def test_get_nop_job():
2323

2424
# Assert
2525
assert result.error == 0
26+
assert result.command.startswith("python ")
27+
assert result.command.endswith("tests/jobs/nop.py")

workflow/workflow_abc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class LaunchResult:
1818
error_msg: Optional[str]
1919
instance_id: Optional[str]
2020
task_id: Optional[str]
21+
command: Optional[str]
2122

2223

2324
class InstanceLauncher(ABC):

workflow/workflow_engine.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from informaticsmatters.protobuf.datamanager.pod_message_pb2 import PodMessage
88

9-
from .workflow_abc import DatabaseAdapter, InstanceLauncher, MessageDispatcher
9+
from .workflow_abc import DatabaseAdapter, InstanceLauncher
1010

1111

1212
@dataclass
@@ -33,12 +33,10 @@ def __init__(
3333
*,
3434
instance_launcher: InstanceLauncher,
3535
db_adapter: DatabaseAdapter,
36-
msg_dispatcher: MessageDispatcher,
3736
):
3837
# Keep the dependent objects
3938
self._instance_launcher = instance_launcher
4039
self._db_adapter = db_adapter
41-
self._msg_dispatcher = msg_dispatcher
4240

4341
def handle_pod_message(
4442
self,

workflow/worklfow_validator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def validate(
6767
workflow_definition: Dict[str, Any],
6868
workflow_inputs: Optional[Dict[str, Any]] = None,
6969
) -> ValidationResult:
70-
"""Validates the workflow definition (and inputs) based
71-
on the provided 'level'."""
70+
"""Validates the workflow definition (and inputs)
71+
based on the provided 'level'."""
7272
assert level in ValidationLevel
7373
assert isinstance(workflow_definition, dict)
7474
if workflow_inputs:

0 commit comments

Comments
 (0)