Skip to content

Commit 340670e

Browse files
committed
fix: stashing
1 parent 2a6b708 commit 340670e

8 files changed

+128
-78
lines changed

tests/test_workflow_engine_examples.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ def test_workflow_engine_example_smiles_to_file(basic_engine):
206206
assert project_file_exists(output_file)
207207

208208

209+
@pytest.mark.skip("Unrealistic test")
209210
def test_workflow_engine_shortcut_example_1(basic_engine):
210211
# Arrange
211212
md, da = basic_engine
213+
212214
# Make sure files that should be generated by the test
213215
# do not exist before we run the test.
214216
output_file_a = "a.sdf"
@@ -234,9 +236,17 @@ def test_workflow_engine_shortcut_example_1(basic_engine):
234236
assert project_file_exists(output_file_b)
235237

236238

239+
@pytest.mark.skip("temporary skip")
237240
def test_workflow_engine_simple_python_molprops(basic_engine):
238241
# Arrange
239242
md, da = basic_engine
243+
244+
da.mock_get_running_workflow_step_output_values_for_output(
245+
step_name="step2",
246+
output_variable="outputFile",
247+
output="step1.out.smi",
248+
)
249+
240250
# Make sure files that should be generated by the test
241251
# do not exist before we run the test.
242252
output_file_1 = "step1.out.smi"
@@ -318,6 +328,13 @@ def test_workflow_engine_simple_python_molprops(basic_engine):
318328
def test_workflow_engine_simple_python_molprops_with_options(basic_engine):
319329
# Arrange
320330
md, da = basic_engine
331+
332+
da.mock_get_running_workflow_step_output_values_for_output(
333+
step_name="step1",
334+
output_variable="outputFile",
335+
output="step1.out.smi",
336+
)
337+
321338
# Make sure files that should be generated by the test
322339
# do not exist before we run the test.
323340
output_file_1 = "step1.out.smi"
@@ -383,6 +400,7 @@ def test_workflow_engine_simple_python_molprops_with_options(basic_engine):
383400
"simple-python-molprops-with-options",
384401
{
385402
"candidateMolecules": input_file_1,
403+
"outputFile": output_file_1,
386404
"rdkitPropertyName": "prop",
387405
"rdkitPropertyValue": 1.2,
388406
},

tests/wapi_adapter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,14 @@ def realise_outputs(
448448
# Methods not declared in the ABC
449449

450450
def mock_get_running_workflow_step_output_values_for_output(
451-
self, *, step_name: str, output_variable: str, output: list[str]
451+
self, *, step_name: str, output_variable: str, output: list[str] | str
452452
) -> None:
453453
"""Sets the output response for a step.
454454
Limitation is that there can only be one record for each step name
455455
so, for now, the output_variable is superfluous and only used
456456
to check the output variable name matches."""
457457
assert isinstance(step_name, str)
458458
assert isinstance(output_variable, str)
459-
assert isinstance(output, list)
460459

461460
UnitTestWorkflowAPIAdapter.lock.acquire()
462461
with open(_MOCK_STEP_OUTPUT_FILE, "rb") as pickle_file:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
version: "1.0.0"
1515
outputs:
1616
- output: 'outputFile'
17-
as: 'a.sdf'
17+
# as: 'a.sdf'
1818

1919
- name: example-1-step-2
2020
description: The first step
@@ -29,4 +29,4 @@ steps:
2929
output: 'outputFile'
3030
outputs:
3131
- output: 'outputFile'
32-
as: 'b.sdf'
32+
# as: 'b.sdf'

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ steps:
3131
workflow-input: candidateMolecules
3232
outputs:
3333
- output: outputFile
34-
# as: chunk_*.smi
3534

3635
- name: parallel-step
3736
description: Add some params
@@ -52,19 +51,3 @@ steps:
5251
output: outputFile
5352
outputs:
5453
- output: outputFile
55-
# as: parallel-step.out.smi
56-
57-
# - name: final-step
58-
# description: Collate results
59-
# specification:
60-
# collection: workflow-engine-unit-test-jobs
61-
# job: concatenate
62-
# version: "1.0.0"
63-
# inputs:
64-
# - input: inputFile
65-
# from:
66-
# step: parallel-step
67-
# output: outputFile
68-
# outputs:
69-
# - output: outputFile
70-
# # as: final-step.out.smi

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

Lines changed: 71 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,82 @@ variables:
5353
minimum: 0
5454
maximum: 1
5555

56-
variable-mapping:
57-
inputs:
58-
- name: candidateMolecules
59-
outputs:
60-
- name: clusteredMolecules
61-
from:
62-
step: step2
63-
output: outputFile
64-
options:
65-
- name: rdkitPropertyName
66-
default: name
67-
as:
68-
- option: name
69-
step: step1
70-
- name: rdkitPropertyValue
71-
as:
72-
- option: value
73-
step: step1
56+
# variable-mapping:
57+
# inputs:
58+
# - name: candidateMolecules
59+
# outputs:
60+
# - name: outputFile
61+
# from:
62+
# step: step1
63+
# output: outputFile
64+
# - name: clusteredMolecules
65+
# from:
66+
# step: step1
67+
# output: outputFile
68+
# options:
69+
# - name: rdkitPropertyName
70+
# default: name
71+
# as:
72+
# - option: name
73+
# step: step1
74+
# - name: rdkitPropertyValue
75+
# as:
76+
# - option: value
77+
# step: step1
7478

7579
steps:
7680

81+
# - name: step1
82+
# description: Add column 1
83+
# specification:
84+
# collection: workflow-engine-unit-test-jobs
85+
# job: rdkit-molprops
86+
# version: "1.0.0"
87+
# inputs:
88+
# - input: inputFile
89+
# from:
90+
# workflow-input: candidateMolecules
91+
# # outputs:
92+
# # - output: outputFile
93+
94+
# - name: step2
95+
# description: Add column 2
96+
# specification:
97+
# collection: workflow-engine-unit-test-jobs
98+
# job: cluster-butina
99+
# version: "1.0.0"
100+
# variables:
101+
# name: "col2"
102+
# value: "999"
103+
# inputs:
104+
# - input: inputFile
105+
# from:
106+
# step: step1
107+
# output: outputFile
108+
# outputs:
109+
# - output: outputFile
110+
111+
77112
- name: step1
78113
description: Add column 1
79114
specification:
80115
collection: workflow-engine-unit-test-jobs
81116
job: rdkit-molprops
82117
version: "1.0.0"
83-
inputs:
84-
- input: inputFile
118+
variable-mapping:
119+
- name: inputFile
85120
from:
86-
workflow-input: candidateMolecules
87-
outputs:
88-
- output: outputFile
89-
as: step1.out.smi
121+
workflow-variable: candidateMolecules
122+
- name: name
123+
from:
124+
workflow-variable: rdkitPropertyName
125+
- name: value
126+
from:
127+
workflow-variable: rdkitPropertyValue
128+
- name: outputFile
129+
from:
130+
workflow-variable: clusteredMolecules
131+
90132

91133
- name: step2
92134
description: Add column 2
@@ -97,11 +139,11 @@ steps:
97139
variables:
98140
name: "col2"
99141
value: "999"
100-
inputs:
101-
- input: inputFile
142+
variable-mapping:
143+
- name: inputFile
102144
from:
103145
step: step1
104146
output: outputFile
105-
outputs:
106-
- output: outputFile
107-
as: step2.out.smi
147+
- name: outputFile
148+
from:
149+
workflow-variable: outputFile

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ steps:
2929
workflow-input: candidateMolecules
3030
outputs:
3131
- output: outputFile
32-
as: step1.out.smi
3332

3433
- name: step2
3534
description: Add column 2
@@ -47,4 +46,3 @@ steps:
4746
output: outputFile
4847
outputs:
4948
- output: outputFile
50-
as: step2.out.smi

workflow/decoder.py

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import os
7+
from pprint import pprint
78
from typing import Any
89

910
import jsonschema
@@ -225,8 +226,10 @@ def set_step_variables(
225226
"""
226227
result = {}
227228

228-
print("ssv: wf vars", workflow_variables)
229-
print("ssv: inputs", inputs)
229+
print("ssv: wf vars:")
230+
pprint(workflow_variables)
231+
print("ssv: inputs:")
232+
pprint(inputs)
230233
print("ssv: outputs", outputs)
231234
print("ssv: step_outputs", step_outputs)
232235
print("ssv: prev step outputs", previous_step_outputs)
@@ -240,30 +243,35 @@ def set_step_variables(
240243
p_val = workflow_variables[val["workflow-input"]]
241244
result[p_key] = p_val
242245
elif "step" in val.keys():
243-
for out in previous_step_outputs:
244-
if out["output"] == val["output"]:
245-
# p_val = out["as"]
246-
if step_outputs["output"]:
247-
p_val = step_outputs["output"]
248-
print("\n!!!!!!!!!!!!!if clause!!!!!!!!!!!!!!!!!!!!!\n")
249-
print(p_val)
250-
else:
251-
# what do I need to do here??
252-
print("\n!!!!!!!!!!!!!else clause!!!!!!!!!!!!!!!!!!!!!\n")
253-
print(out)
254-
print(val)
255-
256-
# this bit handles multiple inputs: if a step
257-
# requires input from multiple steps, add them to
258-
# the list in result dict. this is the reason for
259-
# mypy ignore statements, mypy doesn't understand
260-
# redefinition
261-
if p_key in result:
262-
if not isinstance(result[p_key], set):
263-
result[p_key] = {result[p_key]} # type: ignore [assignment]
264-
result[p_key].add(p_val) # type: ignore [attr-defined]
265-
else:
266-
result[p_key] = p_val
246+
# this links the variable to previous step output
247+
if previous_step_outputs:
248+
for out in previous_step_outputs:
249+
if out["output"] == val["output"]:
250+
# p_val = out["as"]
251+
if step_outputs["output"]:
252+
p_val = step_outputs["output"]
253+
print("\n!!!!!!!!!!!!!if clause!!!!!!!!!!!!!!!!!!!!!\n")
254+
print(p_val)
255+
else:
256+
# what do I need to do here??
257+
print("\n!!!!!!!!!!!!!else clause!!!!!!!!!!!!!!!!!!!!!\n")
258+
print(out)
259+
print(val)
260+
261+
# this bit handles multiple inputs: if a step
262+
# requires input from multiple steps, add them to
263+
# the list in result dict. this is the reason for
264+
# mypy ignore statements, mypy doesn't understand
265+
# redefinition
266+
if p_key in result:
267+
if not isinstance(result[p_key], set):
268+
result[p_key] = {result[p_key]} # type: ignore [assignment]
269+
result[p_key].add(p_val) # type: ignore [attr-defined]
270+
else:
271+
result[p_key] = p_val
272+
else:
273+
if val["output"] in workflow_variables:
274+
result[p_key] = workflow_variables[val["output"]]
267275

268276
for item in outputs:
269277
p_key = item["output"]

workflow/workflow_engine.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ def _validate_step_command(
512512
except AssertionError:
513513
print("no output for step", running_workflow_step_id, k, v)
514514

515+
print("final prev step outputs", previous_step_outputs)
516+
515517
step_vars = set_step_variables(
516518
workflow=workflow,
517519
workflow_variables=all_variables,

0 commit comments

Comments
 (0)