diff --git a/client/src/components/Workflow/Editor/Index.vue b/client/src/components/Workflow/Editor/Index.vue index 49e9033a1670..814cdc6c81d2 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 93c96cb869df..81d4b15674cb 100644 --- a/client/src/stores/workflowStepStore.ts +++ b/client/src/stores/workflowStepStore.ts @@ -107,6 +107,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 1f1467d5b330..6106d0043517 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -1083,12 +1083,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.") @@ -1166,6 +1163,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 2523819056d8..90b07c7a802b 100644 --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -585,7 +585,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(), @@ -593,6 +593,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): diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index 9d3edcbc79c4..55d1d5b8264a 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):