From 974bde595951ecd31ee5f60b0b7c6fa7afb4c637 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Thu, 11 Jan 2024 21:59:58 +0100 Subject: [PATCH 1/3] consider Null inputs as a possibility to allow the pick value tool to create an empty file. --- lib/galaxy/tools/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index d94f5b4d3c0f..653db7db15b4 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2857,6 +2857,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 == 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 From d44e3d4f1b61c3337785309705679731e1e9bfc1 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Fri, 12 Jan 2024 13:36:25 +0100 Subject: [PATCH 2/3] Style fix Co-authored-by: Marius van den Beek --- lib/galaxy/tools/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 653db7db15b4..e331e465111f 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2857,7 +2857,7 @@ 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 == None: + 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"] From 71f0e496599c6f1fd3c4c67549ec053218099ae8 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 19 Feb 2024 10:33:20 +0100 Subject: [PATCH 3/3] Test that optional data to bool coercion works --- test/integration/test_workflow_invocation.py | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/test/integration/test_workflow_invocation.py b/test/integration/test_workflow_invocation.py index 5ac1fc680f8a..72276bf77979 100644 --- a/test/integration/test_workflow_invocation.py +++ b/test/integration/test_workflow_invocation.py @@ -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 @@ -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: