|
1 | 1 | """Workflow abstract base classes.
|
2 |
| -Interface definitions of class instances that must be made available to the Engine. |
| 2 | +
|
| 3 | +A module that provides interface definitions for classes that must be made available |
| 4 | +to the engine. |
| 5 | +
|
| 6 | +Before go any further it is important to understand that a Workflow 'Step' is realised |
| 7 | +by the execution of a Data Manager 'Job'. A 'Step' is simnply the definition of |
| 8 | +a Job's execution withion the context of a 'Workflow'. We also talk about 'Instances'. |
| 9 | +Instances are a Data Manger concept. They are an object (and database Table) |
| 10 | +represening the running state of a Job. |
| 11 | +
|
| 12 | +When steps 'Steps' are run the are represented by 'Jobs' that run as an 'Instance'. |
| 13 | +
|
| 14 | +To this end the workflow engine relies on a two broad external services, encapsulated |
| 15 | +by abstract class definitions we define here: - |
| 16 | +
|
| 17 | +- An 'Instance Laucncher' to facilitate the execution of Jobs |
| 18 | +- An API 'wrapper' providing access to an underling database that stores |
| 19 | + Workflows, RunningWorkflows, RunningWorkflowSteps, and Instances. |
| 20 | +
|
| 21 | +Module philosophy |
| 22 | +----------------- |
| 23 | +The engine is responsible for orchestrating Step exection (executing Jobs) but does not |
| 24 | +contain the logic that is able to run them. This is because a) job execution |
| 25 | +(in Kubernetes) is a complex affair and b) the Data Manager already provides this |
| 26 | +logic. Instead the engine defines an ABC for an 'InstanceLaucnher' and the |
| 27 | +DM provides the implementation. The engine simply has to create a 'LaunchParameter' |
| 28 | +object describign the Job to be laucnhed (including variables etc.) and then |
| 29 | +relies on the Instance Launcher to effect the execution. |
| 30 | +
|
| 31 | +The engine also does not consist of any persistence capability and instead relies on the |
| 32 | +Data Manager's database to host suitable 'Workflow', 'RunningWorkflow', |
| 33 | +and 'RunningWorkflowStep' tables. The 'WorkflowAPIAdapter' defined here provides an |
| 34 | +interface that a concrete implementation uses to allow access to and modification |
| 35 | +of records withing these tables. |
| 36 | +
|
| 37 | +The engine does not create or remove records directly, they are created either by the |
| 38 | +Data Manager via its API or the Instance laucnher when as it starts Jobs (Steps). |
| 39 | +The DM API creates a Workflow record when the user creates a Workflow. |
| 40 | +It also creates RunnignWorkflow records (while also validating them) when the |
| 41 | +user 'runs' a workflow. It also creates RunningWorkflowStep records to track the |
| 42 | +execution state of each step when the Instance lancher is called upon |
| 43 | +to start a Step. |
| 44 | +
|
| 45 | +The instance launcher is controlled by a complex set of 'parameters' (a |
| 46 | +'LaunchPrameters' dataclass object) that comprehensively descibe the Job - |
| 47 | +it's variables, and inputs and outputs. The instance launcher provies just one method: |
| 48 | +'launch()'. It takes a paramters object, and in return the yields a 'LaunchResult' |
| 49 | +dataclass object that contains the record IDs of the instance created, and the |
| 50 | +corresponding RunningWorkflowStep. The result also describes any launch error. |
| 51 | +If there is a laucnh error the tep can assume to have not started. if there is |
| 52 | +no error the step will (probably) start. |
3 | 53 | """
|
4 | 54 |
|
5 | 55 | from abc import ABC, abstractmethod
|
6 | 56 | from dataclasses import dataclass
|
7 | 57 | from typing import Any
|
8 | 58 |
|
9 |
| -from google.protobuf.message import Message |
10 |
| - |
11 | 59 |
|
12 | 60 | @dataclass
|
13 | 61 | class LaunchParameters:
|
@@ -358,11 +406,3 @@ def get_running_workflow_step_output_values_for_output(
|
358 | 406 | # {
|
359 | 407 | # "output": ["dir/file1.sdf", "dir/file2.sdf"]
|
360 | 408 | # }
|
361 |
| - |
362 |
| - |
363 |
| -class MessageDispatcher(ABC): |
364 |
| - """The class handling the sending of messages (on the Data Manager message bus).""" |
365 |
| - |
366 |
| - @abstractmethod |
367 |
| - def send(self, message: Message) -> None: |
368 |
| - """Send a message""" |
|
0 commit comments