Skip to content

Commit

Permalink
If loading a workflow without a version by instance id - use that ins…
Browse files Browse the repository at this point in the history
…tance.
  • Loading branch information
jmchilton committed Oct 14, 2024
1 parent 033be4f commit 45840a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7748,6 +7748,15 @@ def get_internal_version(self, version):
raise galaxy.exceptions.RequestParameterInvalidException("Version does not exist")
return list(reversed(self.workflows))[version]

def get_internal_version_by_id(self, workflow_instance_id: int):
sa_session = object_session(self)
workflow = sa_session.get(Workflow, workflow_instance_id)
if not workflow:
raise galaxy.exceptions.ObjectNotFound()
elif workflow.stored_workflow != self:
raise galaxy.exceptions.RequestParameterInvalidException()
return workflow

def version_of(self, workflow):
for version, workflow_instance in enumerate(reversed(self.workflows)):
if workflow_instance.id == workflow.id:
Expand Down
5 changes: 4 additions & 1 deletion lib/galaxy/webapps/galaxy/services/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def invoke_workflow(
by_stored_id = not payload.instance
stored_workflow = self._workflows_manager.get_stored_accessible_workflow(trans, workflow_id, by_stored_id)
version = payload.version
workflow = stored_workflow.get_internal_version(version)
if version is None and payload.instance:
workflow = stored_workflow.get_internal_version_by_id(workflow_id)
else:
workflow = stored_workflow.get_internal_version(version)
run_configs = build_workflow_run_configs(trans, workflow, payload.model_dump(exclude_unset=True))
is_batch = payload.batch
if not is_batch and len(run_configs) != 1:
Expand Down

0 comments on commit 45840a3

Please sign in to comment.