Skip to content

Commit e3ece79

Browse files
author
Alan Christie
committed
refactor: Major refactor (new variable-mapping schema)
1 parent 340670e commit e3ece79

18 files changed

+283
-848
lines changed

tests/test_decoder.py

Lines changed: 13 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@
4343
)
4444
assert _SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW
4545

46-
_DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW_FILE: str = os.path.join(
47-
os.path.dirname(__file__),
48-
"workflow-definitions",
49-
"duplicate-workflow-variable-names.yaml",
50-
)
51-
with open(
52-
_DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW_FILE, "r", encoding="utf8"
53-
) as workflow_file:
54-
_DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW: Dict[str, Any] = yaml.safe_load(
55-
workflow_file
56-
)
57-
assert _DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW
58-
5946
_SIMPLE_PYTHON_PARALLEL_FILE: str = os.path.join(
6047
os.path.dirname(__file__),
6148
"workflow-definitions",
@@ -78,15 +65,6 @@
7865
)
7966
assert _STEP_SPECIFICATION_VARIABLE_NAMES_WORKFLOW
8067

81-
_WORKFLOW_OPTIONS_WORKFLOW_FILE: str = os.path.join(
82-
os.path.dirname(__file__),
83-
"workflow-definitions",
84-
"workflow-options.yaml",
85-
)
86-
with open(_WORKFLOW_OPTIONS_WORKFLOW_FILE, "r", encoding="utf8") as workflow_file:
87-
_WORKFLOW_OPTIONS: Dict[str, Any] = yaml.safe_load(workflow_file)
88-
assert _WORKFLOW_OPTIONS
89-
9068

9169
def test_validate_schema_for_minimal():
9270
# Arrange
@@ -144,7 +122,7 @@ def test_validate_schema_for_shortcut_example_1():
144122
assert error is None
145123

146124

147-
def test_validate_schema_for_python_simple_molprops():
125+
def test_validate_schema_for_simple_python_molprops():
148126
# Arrange
149127

150128
# Act
@@ -164,16 +142,7 @@ def test_validate_schema_for_step_specification_variable_names():
164142
assert error is None
165143

166144

167-
def test_validate_schema_for_workflow_options():
168-
# Arrange
169-
170-
# Act
171-
error = decoder.validate_schema(_WORKFLOW_OPTIONS)
172-
173-
# Assert
174-
assert error is None
175-
176-
145+
@pytest.mark.skip(reason="DO not support combination atm")
177146
def test_validate_schema_for_simple_python_parallel():
178147
# Arrange
179148

@@ -188,7 +157,7 @@ def test_get_workflow_variables_for_smiple_python_molprops():
188157
# Arrange
189158

190159
# Act
191-
wf_variables = decoder.get_variable_names(_SIMPLE_PYTHON_MOLPROPS_WORKFLOW)
160+
wf_variables = decoder.get_workflow_variable_names(_SIMPLE_PYTHON_MOLPROPS_WORKFLOW)
192161

193162
# Assert
194163
assert len(wf_variables) == 2
@@ -228,91 +197,6 @@ def test_get_workflow_steps():
228197
assert steps[1]["name"] == "step2"
229198

230199

231-
def test_get_workflow_variables_for_duplicate_variables():
232-
# Arrange
233-
234-
# Act
235-
names = decoder.get_variable_names(_DUPLICATE_WORKFLOW_VARIABLE_NAMES_WORKFLOW)
236-
237-
# Assert
238-
assert len(names) == 2
239-
assert names[0] == "x"
240-
assert names[1] == "x"
241-
242-
243-
def test_get_required_variable_names_for_simnple_python_molprops_with_options():
244-
# Arrange
245-
246-
# Act
247-
rqd_variables = decoder.get_required_variable_names(
248-
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW
249-
)
250-
251-
# Assert
252-
assert len(rqd_variables) == 2
253-
assert "candidateMolecules" in rqd_variables
254-
assert "rdkitPropertyValue" in rqd_variables
255-
256-
257-
def test_set_variables_from_options_for_step_for_simnple_python_molprops_with_options():
258-
# Arrange
259-
variables = {
260-
"rdkitPropertyName": "propertyName",
261-
"rdkitPropertyValue": "propertyValue",
262-
}
263-
264-
# Act
265-
new_variables = decoder.set_variables_from_options_for_step(
266-
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW,
267-
variables,
268-
"step1",
269-
)
270-
271-
# Assert
272-
assert len(new_variables) == 2
273-
assert "name" in new_variables
274-
assert "value" in new_variables
275-
assert new_variables["name"] == "propertyName"
276-
assert new_variables["value"] == "propertyValue"
277-
278-
279-
def test_get_workflow_inputs_for_step_with_name_step1():
280-
# Arrange
281-
282-
# Act
283-
inputs = decoder.get_workflow_job_input_names_for_step(
284-
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "step1"
285-
)
286-
287-
# Assert
288-
assert len(inputs) == 1
289-
assert "inputFile" in inputs
290-
291-
292-
def test_get_workflow_inputs_for_step_with_name_step2():
293-
# Arrange
294-
295-
# Act
296-
inputs = decoder.get_workflow_job_input_names_for_step(
297-
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "step2"
298-
)
299-
300-
# Assert
301-
assert not inputs
302-
303-
304-
def test_get_workflow_inputs_for_step_with_unkown_step_name():
305-
# Arrange
306-
307-
# Act
308-
inputs = decoder.get_workflow_job_input_names_for_step(
309-
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "unknown"
310-
)
311-
312-
# Assert
313-
assert not inputs
314-
315-
316200
def test_get_workflow_outputs_for_step_with_name_step1():
317201
# Arrange
318202

@@ -351,11 +235,16 @@ def test_get_workflow_outputs_for_step_with_unkown_step_name():
351235

352236
def test_get_step_input_variable_names_when_duplicates():
353237
# Arrange
238+
workflow_filename: str = os.path.join(
239+
os.path.dirname(__file__),
240+
"workflow-definitions",
241+
"duplicate-step-input-output-variable-names.yaml",
242+
)
243+
with open(workflow_filename, "r", encoding="utf8") as wf_file:
244+
definition: Dict[str, Any] = yaml.safe_load(wf_file)
354245

355246
# Act
356-
inputs = decoder.get_step_input_variable_names(
357-
_SIMPLE_PYTHON_PARALLEL_WORKFLOW, "final-step"
358-
)
247+
inputs = decoder.get_step_input_variable_names(definition, "step-1")
359248

360249
# Assert
361250
assert len(inputs) == 2
@@ -368,13 +257,13 @@ def test_get_step_output_variable_names_when_duplicates():
368257
workflow_filename: str = os.path.join(
369258
os.path.dirname(__file__),
370259
"workflow-definitions",
371-
"duplicate-step-output-variable-names.yaml",
260+
"duplicate-step-input-output-variable-names.yaml",
372261
)
373262
with open(workflow_filename, "r", encoding="utf8") as wf_file:
374263
definition: Dict[str, Any] = yaml.safe_load(wf_file)
375264

376265
# Act
377-
outputs = decoder.get_step_output_variable_names(definition, "step-1")
266+
outputs = decoder.get_step_output_variable_names(definition, "step-2")
378267

379268
# Assert
380269
assert len(outputs) == 2

tests/test_workflow_validator_for_create_level.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def test_validate_minimal():
2626

2727
def test_validate_example_nop_file():
2828
# Arrange
29-
workflow_file: str = os.path.join(
29+
workflow_filename: str = os.path.join(
3030
os.path.dirname(__file__), "workflow-definitions", "example-nop-fail.yaml"
3131
)
32-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
32+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
3333
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
3434
assert workflow
3535

@@ -46,10 +46,10 @@ def test_validate_example_nop_file():
4646

4747
def test_validate_example_smiles_to_file():
4848
# Arrange
49-
workflow_file: str = os.path.join(
49+
workflow_filename: str = os.path.join(
5050
os.path.dirname(__file__), "workflow-definitions", "example-smiles-to-file.yaml"
5151
)
52-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
52+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
5353
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
5454
assert workflow
5555

@@ -66,10 +66,10 @@ def test_validate_example_smiles_to_file():
6666

6767
def test_validate_example_two_step_nop():
6868
# Arrange
69-
workflow_file: str = os.path.join(
69+
workflow_filename: str = os.path.join(
7070
os.path.dirname(__file__), "workflow-definitions", "example-two-step-nop.yaml"
7171
)
72-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
72+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
7373
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
7474
assert workflow
7575

@@ -86,10 +86,10 @@ def test_validate_example_two_step_nop():
8686

8787
def test_validate_shortcut_example_1():
8888
# Arrange
89-
workflow_file: str = os.path.join(
89+
workflow_filename: str = os.path.join(
9090
os.path.dirname(__file__), "workflow-definitions", "shortcut-example-1.yaml"
9191
)
92-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
92+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
9393
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
9494
assert workflow
9595

@@ -106,10 +106,10 @@ def test_validate_shortcut_example_1():
106106

107107
def test_validate_simple_python_molprops():
108108
# Arrange
109-
workflow_file: str = os.path.join(
109+
workflow_filename: str = os.path.join(
110110
os.path.dirname(__file__), "workflow-definitions", "simple-python-molprops.yaml"
111111
)
112-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
112+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
113113
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
114114
assert workflow
115115

@@ -126,12 +126,12 @@ def test_validate_simple_python_molprops():
126126

127127
def test_validate_simple_python_molprops_with_options():
128128
# Arrange
129-
workflow_file: str = os.path.join(
129+
workflow_filename: str = os.path.join(
130130
os.path.dirname(__file__),
131131
"workflow-definitions",
132132
"simple-python-molprops-with-options.yaml",
133133
)
134-
with open(workflow_file, "r", encoding="utf8") as workflow_file:
134+
with open(workflow_filename, "r", encoding="utf8") as workflow_file:
135135
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
136136
assert workflow
137137

0 commit comments

Comments
 (0)