Skip to content

Commit 5e2c8bc

Browse files
author
Alan Christie
committed
refactor: variable-map is now 'plumbing' and Translation is a 'Connector'
1 parent 4b1e868 commit 5e2c8bc

12 files changed

+61
-62
lines changed

tests/test_workflow_engine_examples.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,12 @@ def test_workflow_engine_simple_python_molprops_with_options(basic_engine):
398398
assert project_file_exists(output_file_2)
399399

400400

401-
def test_workflow_engine_simple_python_fanout(basic_engine):
401+
def test_workflow_engine_simple_python_split_combine(basic_engine):
402402
# Arrange
403403
md, da = basic_engine
404404

405405
da.mock_get_running_workflow_step_output_values_for_output(
406-
step_name="first-step",
406+
step_name="split",
407407
output_variable="outputBase",
408408
output=["chunk_1.smi", "chunk_2.smi"],
409409
)
@@ -427,7 +427,7 @@ def test_workflow_engine_simple_python_fanout(basic_engine):
427427
r_wfid = start_workflow(
428428
md,
429429
da,
430-
"simple-python-fanout",
430+
"simple-python-split-combine",
431431
{"candidateMolecules": input_file_1},
432432
)
433433

tests/workflow-definitions/duplicate-step-input-output-variable-names.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
variables:
1515
name: "col1"
1616
value: 123
17-
variable-mapping:
17+
plumbing:
1818
- variable: inputFile
1919
from-workflow:
2020
variable: candidateMolecules
@@ -34,7 +34,7 @@ steps:
3434
variables:
3535
name: "col2"
3636
value: "999"
37-
variable-mapping:
37+
plumbing:
3838
- variable: inputFile
3939
from-step:
4040
name: step1

tests/workflow-definitions/example-smiles-to-file.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ steps:
1313
collection: workflow-engine-unit-test-jobs
1414
job: smiles-to-file
1515
version: "1.0.0"
16-
variable-mapping:
16+
plumbing:
1717
- variable: outputFile
1818
from-workflow:
1919
variable: outputFile

tests/workflow-definitions/replicate-using-undeclared-input.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
variables:
1515
name: "col1"
1616
value: 123
17-
variable-mapping:
17+
plumbing:
1818
- variable: inputFile
1919
from-workflow:
2020
variable: candidateMolecules
@@ -33,7 +33,7 @@ steps:
3333
replicate:
3434
using:
3535
variable: y
36-
variable-mapping:
36+
plumbing:
3737
- variable: inputFile
3838
from-step:
3939
name: step-1

tests/workflow-definitions/shortcut-example-1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ steps:
1919
collection: workflow-engine-unit-test-jobs
2020
job: shortcut-example-1-process-b
2121
version: "1.0.0"
22-
variable-mapping:
22+
plumbing:
2323
- variable: inputFile
2424
from-step:
2525
name: example-1-step-1

tests/workflow-definitions/simple-python-molprops-with-options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ steps:
1313
version: "1.0.0"
1414
variables:
1515
outputFile: step1.out.smi
16-
variable-mapping:
16+
plumbing:
1717
- variable: inputFile
1818
from-workflow:
1919
variable: candidateMolecules
@@ -33,7 +33,7 @@ steps:
3333
variables:
3434
name: "col2"
3535
value: "999"
36-
variable-mapping:
36+
plumbing:
3737
- variable: inputFile
3838
from-step:
3939
name: step1

tests/workflow-definitions/simple-python-molprops.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ steps:
1515
name: "col1"
1616
value: 123
1717
outputFile: "results.smi"
18-
variable-mapping:
18+
plumbing:
1919
- variable: inputFile
2020
from-workflow:
2121
variable: candidateMolecules
@@ -29,7 +29,7 @@ steps:
2929
variables:
3030
name: "col2"
3131
value: "999"
32-
variable-mapping:
32+
plumbing:
3333
- variable: inputFile
3434
from-step:
3535
name: step1

tests/workflow-definitions/simple-python-parallel.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
variables:
1515
name: "unnecessary"
1616
value: "0"
17-
variable-mapping:
17+
plumbing:
1818
- variable: inputFile
1919
from-workflow:
2020
variable: candidateMolecules
@@ -28,7 +28,7 @@ steps:
2828
variables:
2929
name: "desc1"
3030
value: "777"
31-
variable-mapping:
31+
plumbing:
3232
- variable: inputFile
3333
from-step:
3434
name: first-step
@@ -43,7 +43,7 @@ steps:
4343
variables:
4444
name: "desc2"
4545
value: "999"
46-
variable-mapping:
46+
plumbing:
4747
- variable: inputFile
4848
from-step:
4949
name: first-step

tests/workflow-definitions/simple-python-fanout.yaml renamed to tests/workflow-definitions/simple-python-split-combine.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ kind: DataManagerWorkflow
33
kind-version: "2025.2"
44
name: python-workflow
55
description: >-
6-
A simple parallel workflow. Input is split into N chunks and N processes of the same job is started
6+
A simple parallel workflow. The input is split into chunks and a number outputFile
7+
parallel steps processes these outputs. Finally a combine step concatenates the
8+
files.
79
810
steps:
9-
- name: first-step
11+
- name: split
1012
description: Split an input file
1113
specification:
1214
collection: workflow-engine-unit-test-jobs
@@ -16,7 +18,7 @@ steps:
1618
name: count
1719
value: "1"
1820
outputBase: chunk
19-
variable-mapping:
21+
plumbing:
2022
- variable: inputFile
2123
from-workflow:
2224
variable: candidateMolecules
@@ -31,10 +33,10 @@ steps:
3133
name: desc1
3234
value: "777"
3335
outputFile: results.smi
34-
variable-mapping:
36+
plumbing:
3537
- variable: inputFile
3638
from-step:
37-
name: first-step
39+
name: split
3840
variable: outputBase
3941
out:
4042
- outputFile

workflow/decoder.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626

2727
@dataclass
28-
class Translation:
29-
"""A source ("in_") to destination ("out") variable map."""
28+
class Connector:
29+
"""A connection - connexts a plumbing source variable ("in_")
30+
to destination variable ("out")."""
3031

3132
in_: str
3233
out: str
@@ -83,13 +84,13 @@ def get_description(definition: dict[str, Any]) -> str | None:
8384

8485
def get_workflow_variable_names(definition: dict[str, Any]) -> set[str]:
8586
"""Given a Workflow definition this function returns all the names of the
86-
variables that need to be defined at the workflow level. These are the 'variables'
87-
used in every steps' variabale-mapping block.
87+
variables defined in steps that need to be defined at the workflow level.
88+
These are the 'variables' used in every step's 'plumbing' block.
8889
"""
8990
wf_variable_names: set[str] = set()
9091
steps: list[dict[str, Any]] = get_steps(definition)
9192
for step in steps:
92-
if v_map := step.get("variable-mapping"):
93+
if v_map := step.get("plumbing"):
9394
for v in v_map:
9495
if "from-workflow" in v:
9596
wf_variable_names.add(v["from-workflow"]["variable"])
@@ -126,40 +127,38 @@ def get_step_input_variable_names(
126127
return variable_names
127128

128129

129-
def get_step_workflow_variable_mapping(*, step: dict[str, Any]) -> list[Translation]:
130+
def get_step_workflow_plumbing(*, step: dict[str, Any]) -> list[Connector]:
130131
"""Returns a list of workflow vaiable name to step variable name
131132
Translation objects for the given step."""
132-
variable_mapping: list[Translation] = []
133-
if "variable-mapping" in step:
134-
for v_map in step["variable-mapping"]:
133+
variable_mapping: list[Connector] = []
134+
if "plumbing" in step:
135+
for v_map in step["plumbing"]:
135136
if "from-workflow" in v_map:
136137
variable_mapping.append(
137-
Translation(
138+
Connector(
138139
in_=v_map["from-workflow"]["variable"], out=v_map["variable"]
139140
)
140141
)
141142
return variable_mapping
142143

143144

144-
def get_step_prior_step_variable_mapping(
145-
*, step: dict[str, Any]
146-
) -> dict[str, list[Translation]]:
145+
def get_step_prior_step_plumbing(*, step: dict[str, Any]) -> dict[str, list[Connector]]:
147146
"""Returns list of Translation objects, indexed by prior step name,
148147
that identify source step (output) variable name to this step's (input)
149148
variable name."""
150-
variable_mapping: dict[str, list[Translation]] = {}
151-
if "variable-mapping" in step:
152-
for v_map in step["variable-mapping"]:
149+
variable_mapping: dict[str, list[Connector]] = {}
150+
if "plumbing" in step:
151+
for v_map in step["plumbing"]:
153152
if "from-step" in v_map:
154153
step_name = v_map["from-step"]["name"]
155154
step_variable = v_map["from-step"]["variable"]
156155
# Tuple is "from" -> "to"
157156
if step_name in variable_mapping:
158157
variable_mapping[step_name].append(
159-
Translation(in_=step_variable, out=v_map["variable"])
158+
Connector(in_=step_variable, out=v_map["variable"])
160159
)
161160
else:
162161
variable_mapping[step_name] = [
163-
Translation(in_=step_variable, out=v_map["variable"])
162+
Connector(in_=step_variable, out=v_map["variable"])
164163
]
165164
return variable_mapping

0 commit comments

Comments
 (0)