Skip to content

Commit

Permalink
Merge pull request #17271 from bernt-matthias/topic/null-exec-post
Browse files Browse the repository at this point in the history
Consider Null inputs
  • Loading branch information
mvdbeek authored Feb 23, 2024
2 parents 4e3ed4c + 71f0e49 commit 327b706
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2864,6 +2864,8 @@ def exec_after_process(self, app, inp_data, out_data, param_dict, job=None, **kw
if val.output_type == "data":
with open(out_data[key].get_file_name()) as f:
src = json.load(f)
if src is None:
continue
assert isinstance(src, dict), f"Expected dataset 'src' to be a dictionary - actual type is {type(src)}"
dataset_id = src["id"]
copy_object = None
Expand Down
69 changes: 69 additions & 0 deletions test/integration/test_workflow_invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,48 @@
from galaxy_test.base.uses_shed_api import UsesShedApi
from galaxy_test.driver import integration_util

OPTIONAL_INPUT_BOOL_WORKFLOW = """
class: GalaxyWorkflow
inputs:
optional_data:
optional: true
type: data
steps:
optional_data_to_boolean:
tool_id: toolshed.g2.bx.psu.edu/repos/iuc/map_param_value/map_param_value/0.2.0
tool_state:
input_param_type:
mappings:
- from: null
to: false
type: data
output_param_type: boolean
unmapped:
default_value: true
on_unmapped: default
in:
input_param_type|input_param: optional_data
optional_to_non_optional:
tool_id: pick_value
tool_state:
style_cond:
pick_style: first
type_cond:
param_type: data
in:
style_cond|type_cond|pick_from_0|value:
source: optional_data
cat1:
tool_id: cat1
when: $(inputs.when)
in:
input1: optional_to_non_optional/data_param
when: optional_data_to_boolean/output_param_boolean
outputs:
cat1:
outputSource: cat1/out_file1
"""


class TestWorkflowInvocation(integration_util.IntegrationTestCase, UsesShedApi):
dataset_populator: DatasetPopulator
Expand All @@ -18,6 +60,33 @@ def setUp(self):
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
self.workflow_populator = WorkflowPopulator(self.galaxy_interactor)

def test_run_workflow_optional_data_skips_step(self) -> None:
self.install_repository("iuc", "map_param_value", "5ac8a4bf7a8d")
with self.dataset_populator.test_history() as history_id:
summary = self.workflow_populator.run_workflow(OPTIONAL_INPUT_BOOL_WORKFLOW, history_id=history_id)
invocation_details = self.workflow_populator.get_invocation(summary.invocation_id, step_details=True)
for step in invocation_details["steps"]:
if step["workflow_step_label"] == "cat1":
assert sum(1 for j in step["jobs"] if j["state"] == "skipped") == 1

def test_run_workflow_optional_data_provided_runs_step(self) -> None:
self.install_repository("iuc", "map_param_value", "5ac8a4bf7a8d")
with self.dataset_populator.test_history() as history_id:
summary = self.workflow_populator.run_workflow(
OPTIONAL_INPUT_BOOL_WORKFLOW,
test_data={
"optional_data": {
"value": "1.bed",
"type": "File",
}
},
history_id=history_id,
)
invocation_details = self.workflow_populator.get_invocation(summary.invocation_id, step_details=True)
for step in invocation_details["steps"]:
if step["workflow_step_label"] == "cat1":
assert sum(1 for j in step["jobs"] if j["state"] == "ok") == 1, step["jobs"]

def test_run_workflow_with_missing_tool(self):
self.install_repository("iuc", "compose_text_param", "feb3acba1e0a") # 0.1.0
with self.dataset_populator.test_history() as history_id:
Expand Down

0 comments on commit 327b706

Please sign in to comment.