From 5050ccde3df7113846e83d567d38194d783f26e2 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 27 Jun 2024 14:54:55 +0200 Subject: [PATCH 1/2] Add test to make sure when_expression is not lost on refactoring --- test/integration/test_workflow_refactoring.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/integration/test_workflow_refactoring.py b/test/integration/test_workflow_refactoring.py index 6a03d818ce31..d2501090aeef 100644 --- a/test/integration/test_workflow_refactoring.py +++ b/test/integration/test_workflow_refactoring.py @@ -537,6 +537,33 @@ def test_tool_version_upgrade_no_state_change(self): assert len(action_executions[0].messages) == 0 assert self._latest_workflow.step_by_label("the_step").tool_version == "0.2" + def test_tool_version_upgrade_keeps_when_expression(self): + self.workflow_populator.upload_yaml_workflow( + """ +class: GalaxyWorkflow +inputs: + the_bool: + type: boolean +steps: + the_step: + tool_id: multiple_versions + tool_version: '0.1' + state: + inttest: 0 + when: $inputs.the_bool +""" + ) + assert self._latest_workflow.step_by_label("the_step").tool_version == "0.1" + actions: ActionsJson = [ + {"action_type": "upgrade_tool", "step": {"label": "the_step"}}, + ] + action_executions = self._refactor(actions).action_executions + assert len(action_executions) == 1 + assert len(action_executions[0].messages) == 0 + step = self._latest_workflow.step_by_label("the_step") + assert step.tool_version == "0.2" + assert step.when_expression + def test_tool_version_upgrade_state_added(self): self.workflow_populator.upload_yaml_workflow( """ From ed8dc4b8e29db41993316bf4a65591e73f264219 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 27 Jun 2024 14:54:23 +0200 Subject: [PATCH 2/2] Fix dropped when_expression on workflow/tool_upgrade Fixes https://github.com/galaxyproject/galaxy/issues/18441 --- lib/galaxy/workflow/refactor/execute.py | 3 +++ test/integration/test_workflow_refactoring.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/workflow/refactor/execute.py b/lib/galaxy/workflow/refactor/execute.py index d35cbbbc7785..2582380fc623 100644 --- a/lib/galaxy/workflow/refactor/execute.py +++ b/lib/galaxy/workflow/refactor/execute.py @@ -531,6 +531,9 @@ def _patch_step(self, execution, step, step_def): if upgrade_input["name"] == input_name: matching_input = upgrade_input break + elif step.when_expression and f"inputs.{input_name}" in step.when_expression: + # TODO: eventually track step inputs more formally + matching_input = upgrade_input # In the future check parameter type, format, mapping status... if matching_input is None: diff --git a/test/integration/test_workflow_refactoring.py b/test/integration/test_workflow_refactoring.py index d2501090aeef..d68b8916145b 100644 --- a/test/integration/test_workflow_refactoring.py +++ b/test/integration/test_workflow_refactoring.py @@ -548,9 +548,11 @@ def test_tool_version_upgrade_keeps_when_expression(self): the_step: tool_id: multiple_versions tool_version: '0.1' + in: + when: the_bool state: inttest: 0 - when: $inputs.the_bool + when: $(inputs.when) """ ) assert self._latest_workflow.step_by_label("the_step").tool_version == "0.1"