Skip to content

Commit

Permalink
add test against combined step and implementation mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebachmeier committed Dec 11, 2024
1 parent ba95959 commit 7779ff9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/easylink/implementation_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ step_4a_python_pandas:
step_4b_python_pandas:
steps:
- step_4b
image_path: /mnt/team/simulation_science/priv/engineering/er_ecosystem/images/r-image.sif
image_path: /mnt/team/simulation_science/priv/engineering/er_ecosystem/images/python_pandas.sif
script_cmd: python /dummy_step.py
env:
INPUT_ENV_VARS: "DUMMY_CONTAINER_MAIN_INPUT_FILE_PATHS,DUMMY_CONTAINER_SECONDARY_INPUT_FILE_PATHS"
Expand All @@ -86,7 +86,7 @@ step_4b_python_pandas:
step_4b_r:
steps:
- step_4b
image_path: /mnt/team/simulation_science/priv/engineering/er_ecosystem/images/python_pandas.sif
image_path: /mnt/team/simulation_science/priv/engineering/er_ecosystem/images/r-image.sif
script_cmd: Rscript /dummy_step.R
env:
INPUT_ENV_VARS: "DUMMY_CONTAINER_MAIN_INPUT_FILE_PATHS,DUMMY_CONTAINER_SECONDARY_INPUT_FILE_PATHS"
Expand Down
5 changes: 4 additions & 1 deletion src/easylink/pipeline_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ def validate_implementation_topology(
is topologically consistent with the list of steps intended to be implemented.
"""
subgraph = ImplementationGraph(self).subgraph(nodes)
# NOTE: The subgraph is not necessarily able to be topologically sorted
# in a reproducible way. We instead rely on node name sorting for
# error messages.

# Relabel nodes by schema step
mapping = {
Expand All @@ -326,7 +329,7 @@ def validate_implementation_topology(
}
if not set(mapping.values()) == set(metadata_steps):
raise ValueError(
f"Pipeline configuration nodes {list(mapping.values())} do not match metadata steps {metadata_steps}."
f"Pipeline configuration nodes {sorted(mapping.values())} do not match metadata steps {metadata_steps}."
)
subgraph = nx.relabel_nodes(subgraph, mapping)
# Check for topological inconsistency, i.e. if there is a path from a later node to an earlier node.
Expand Down
1 change: 1 addition & 0 deletions src/easylink/pipeline_schema_constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
TESTING_SCHEMA_PARAMS = {
"integration": tests.SINGLE_STEP_SCHEMA_PARAMS,
"combined_bad_topology": tests.BAD_COMBINED_TOPOLOGY_SCHEMA_PARAMS,
"combined_bad_implementation_names": tests.BAD_COMBINED_TOPOLOGY_SCHEMA_PARAMS,
}
31 changes: 31 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,37 @@
},
},
},
"combined_bad_implementation_names": {
"steps": {
"step_1": {
"implementation": {
"name": "step_1_python_pandas",
},
},
"step_2": {
"implementation": {
"name": "step_2_python_pandas",
},
"combined_implementation_key": "step_3_4", # incorrect key
},
"step_3": {
"implementation": {
"name": "step_3_python_pandas",
},
},
"choice_section": {
"type": "simple",
"step_4": {
"combined_implementation_key": "step_3_4",
},
},
},
"combined_implementations": {
"step_3_4": {
"name": "step_3_and_step_4_combined_python_pandas",
},
},
},
}


Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_pipeline_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ def test_merge_combined_implementations_parallel(default_config_params, test_dir
"Pipeline configuration nodes ['step_1a', 'step_1b'] are not topologically consistent with the intended implementations for ['step_1a', 'step_1b']:\nThere is a path from successor step_1b to predecessor step_1a.",
True,
),
(
"combined_bad_implementation_names",
"Pipeline configuration nodes ['step_2', 'step_4'] do not match metadata steps ['step_3', 'step_4'].",
False,
),
],
)
def test_bad_configuration_raises(
Expand Down

0 comments on commit 7779ff9

Please sign in to comment.