From 5f1471e1ca3d6bb441e4be949d7166d8bf475fdf Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 12 Oct 2023 00:55:02 -0400 Subject: [PATCH 1/3] Get correct tool version in workflow preview And remove the step.type is None condition, which I don't think can happen and even if it can, would have already failed at the module inection in module_factory.from_workflow_step. --- lib/galaxy/managers/workflows.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 4d84e834cd85..511e4a521a82 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -1075,12 +1075,9 @@ def do_inputs(inputs, values, prefix, step, other_values=None): step_dict["label"] = f"Unknown Tool with id '{e.tool_id}'" step_dicts.append(step_dict) continue - if step.type == "tool" or step.type is None: - tool = trans.app.toolbox.get_tool(step.tool_id) - if tool: - step_dict["label"] = step.label or tool.name - else: - step_dict["label"] = f"Unknown Tool with id '{step.tool_id}'" + if step.type == "tool": + tool = trans.app.toolbox.get_tool(step.tool_id, step.tool_version) + step_dict["label"] = step.label or tool.name step_dict["inputs"] = do_inputs(tool.inputs, step.state.inputs, "", step) elif step.type == "subworkflow": step_dict["label"] = step.label or (step.subworkflow.name if step.subworkflow else "Missing workflow.") From 519066ab7ce618d8a8079663fad4d8c66dbcb25d Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 12 Oct 2023 00:57:30 -0400 Subject: [PATCH 2/3] Fix tool version switching for local tools They don't have the version in the tool id, so we need to explicitly include tool_version. --- client/src/components/Workflow/Editor/Index.vue | 2 ++ client/src/stores/workflowStepStore.ts | 1 + lib/galaxy/managers/workflows.py | 2 ++ lib/galaxy/webapps/galaxy/api/workflows.py | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue index 0003f9e5e210..79d3a4c7b83a 100644 --- a/client/src/components/Workflow/Editor/Index.vue +++ b/client/src/components/Workflow/Editor/Index.vue @@ -425,6 +425,7 @@ export default { inputs: response.inputs, outputs: response.outputs, tool_state: response.tool_state, + tool_version: response.tool_version, }); }); }, @@ -550,6 +551,7 @@ export default { outputs: data.outputs, config_form: data.config_form, tool_state: data.tool_state, + tool_version: data.tool_version, errors: data.errors, }; this.onUpdateStep(step); diff --git a/client/src/stores/workflowStepStore.ts b/client/src/stores/workflowStepStore.ts index 67d64fc17370..2eeb80f14f85 100644 --- a/client/src/stores/workflowStepStore.ts +++ b/client/src/stores/workflowStepStore.ts @@ -105,6 +105,7 @@ export interface NewStep { position?: StepPosition; post_job_actions?: PostJobActions; tool_state: Record; + tool_version?: string; tooltip?: string; type: "tool" | "data_input" | "data_collection_input" | "subworkflow" | "parameter_input" | "pause"; uuid?: string; diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 511e4a521a82..ad5ee522b6e0 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -1155,6 +1155,8 @@ def _workflow_to_dict_editor(self, trans, stored, workflow, tooltip=True, is_sub input_connections_type = {} multiple_input = {} # Boolean value indicating if this can be multiple if isinstance(module, ToolModule) and module.tool: + # Serialize tool version + step_dict["tool_version"] = module.tool.version # Determine full (prefixed) names of valid input datasets data_input_names = {} diff --git a/lib/galaxy/webapps/galaxy/api/workflows.py b/lib/galaxy/webapps/galaxy/api/workflows.py index dc3713100660..b09994a9e1f4 100644 --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -589,7 +589,7 @@ def build_module(self, trans: GalaxyWebTransaction, payload=None): module_state: Dict[str, Any] = {} populate_state(trans, module.get_inputs(), inputs, module_state, check=False) module.recover_state(module_state, from_tool_form=True) - return { + step_dict = { "name": module.get_name(), "tool_state": module.get_state(), "content_id": module.get_content_id(), @@ -597,6 +597,9 @@ def build_module(self, trans: GalaxyWebTransaction, payload=None): "outputs": module.get_all_outputs(), "config_form": module.get_config_form(), } + if payload["type"] == "tool": + step_dict["tool_version"] = module.get_version() + return step_dict @expose_api def get_tool_predictions(self, trans: ProvidesUserContext, payload, **kwd): From 2b1518387a3a2f1cf80d06ce2b93ff7bdb0bbc13 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 12 Oct 2023 11:43:07 +0200 Subject: [PATCH 3/3] Extend selenium test for downgrading a tool --- lib/galaxy_test/selenium/test_workflow_editor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index 050d64879a8b..1363adb9a7d7 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -500,6 +500,14 @@ def test_editor_tool_upgrade(self): self.assert_workflow_has_changes_and_save() workflow = self.workflow_populator.download_workflow(workflow_id) assert workflow["steps"]["0"]["tool_version"] == "0.2" + editor.node._(label="multiple_versions").wait_for_and_click() + editor.tool_version_button.wait_for_and_click() + assert self.select_dropdown_item("Switch to 0.1+galaxy6"), "Switch to tool version dropdown item not found" + self.screenshot("workflow_editor_version_downgrade") + self.sleep_for(self.wait_types.UX_RENDER) + self.assert_workflow_has_changes_and_save() + workflow = self.workflow_populator.download_workflow(workflow_id) + assert workflow["steps"]["0"]["tool_version"] == "0.1+galaxy6" @selenium_test def test_editor_tool_upgrade_message(self):