Skip to content

Commit f3bbc6d

Browse files
author
Alan Christie
committed
fix: More fixes for engine
1 parent 5a9903b commit f3bbc6d

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

tests/test_workflow_engine_examples.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def test_workflow_engine_simple_python_molprops(basic_engine):
327327
assert project_file_exists(output_file_2)
328328

329329

330+
@pytest.mark.skip("Unrealistic test")
330331
def test_workflow_engine_simple_python_molprops_with_options(basic_engine):
331332
# Arrange
332333
md, da = basic_engine
@@ -423,6 +424,7 @@ def test_workflow_engine_simple_python_molprops_with_options(basic_engine):
423424
assert project_file_exists(output_file_2)
424425

425426

427+
@pytest.mark.skip("Unrealistic test")
426428
def test_workflow_engine_simple_python_fanout(basic_engine):
427429
# Arrange
428430
md, da = basic_engine

tests/test_workflow_validator_for_run_level.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_validate_example_smiles_to_file():
6262
error = WorkflowValidator.validate(
6363
level=ValidationLevel.RUN,
6464
workflow_definition=workflow,
65+
variables={"smiles": "C", "outputFile": "blob.smi"},
6566
)
6667

6768
# Assert

workflow/decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ def get_step_prior_step_variable_mapping(
137137
# Tuple is "from" -> "to"
138138
if step_name in variable_mapping:
139139
variable_mapping[step_name].append(
140-
(step_variable, v_map["variable"])
140+
(v_map["variable"], step_variable)
141141
)
142142
else:
143-
variable_mapping[step_name] = [(step_variable, v_map["variable"])]
143+
variable_mapping[step_name] = [(v_map["variable"], step_variable)]
144144
return variable_mapping
145145

146146

workflow/workflow_validator.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
from typing import Any
66

77
from .decoder import (
8-
get_step_input_variable_names,
98
get_step_output_variable_names,
9+
get_step_prior_step_variable_mapping,
10+
get_step_workflow_variable_mapping,
1011
get_steps,
1112
get_workflow_variable_names,
1213
validate_schema,
@@ -113,22 +114,36 @@ def _validate_tag_level(
113114
error_msg=[f"Duplicate step names found: {', '.join(duplicate_names)}"],
114115
)
115116
# For each 'replicating' step the replicating variable
116-
# must be declared in the step.
117+
# must be declared in the step - which is either a workflow variable
118+
# or a prior step variable.
117119
for step in get_steps(workflow_definition):
118120
if (
119121
replicate_using_input := step.get("replicate", {})
120122
.get("using", {})
121123
.get("variable")
122124
):
123-
step_name = step["name"]
124-
if replicate_using_input not in get_step_input_variable_names(
125-
workflow_definition, step_name
126-
):
125+
found: bool = False
126+
for variable_map in get_step_workflow_variable_mapping(step=step):
127+
if replicate_using_input == variable_map[0]:
128+
found = True
129+
break
130+
if not found:
131+
for (
132+
step_name,
133+
variable_map_list,
134+
) in get_step_prior_step_variable_mapping(step=step).items():
135+
for variable_map in variable_map_list:
136+
if replicate_using_input == variable_map[0]:
137+
found = True
138+
break
139+
if found:
140+
break
141+
if not found:
127142
return ValidationResult(
128143
error_num=7,
129144
error_msg=[
130145
"Replicate input variable is not declared:"
131-
f" {replicate_using_input} (step={step_name})"
146+
f" {replicate_using_input} (step={step["name"]})"
132147
],
133148
)
134149

0 commit comments

Comments
 (0)