Skip to content

Commit

Permalink
Merge pull request #19335 from mvdbeek/nested_subworkflow_import_fix
Browse files Browse the repository at this point in the history
[24.1] Fix importing shared workflows with deeply nested subworkflows
  • Loading branch information
mvdbeek authored Dec 18, 2024
2 parents 2ca8678 + 2406c87 commit 3a195be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7616,7 +7616,7 @@ class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpd
order_by=lambda: -Workflow.id,
cascade_backrefs=False,
)
latest_workflow = relationship(
latest_workflow: Mapped["Workflow"] = relationship(
"Workflow",
post_update=True,
primaryjoin=(lambda: StoredWorkflow.latest_workflow_id == Workflow.id),
Expand Down Expand Up @@ -7722,7 +7722,7 @@ def show_in_tool_panel(self, user_id):
)
return bool(sa_session.scalar(stmt))

def copy_tags_from(self, target_user, source_workflow):
def copy_tags_from(self, target_user, source_workflow: "StoredWorkflow"):
# Override to only copy owner tags.
for src_swta in source_workflow.owner_tags:
new_swta = src_swta.copy()
Expand Down Expand Up @@ -7895,7 +7895,7 @@ def top_level_stored_workflow(self):
"""
return self.top_level_workflow.stored_workflow

def copy(self, user=None):
def copy(self, user: User):
"""Copy a workflow for a new StoredWorkflow object.
Pass user if user-specific information needed.
Expand Down Expand Up @@ -8206,7 +8206,7 @@ def workflow_output_for(self, output_name):
break
return target_output

def copy_to(self, copied_step, step_mapping, user=None):
def copy_to(self, copied_step: "WorkflowStep", step_mapping: Dict[int, "WorkflowStep"], user: User):
copied_step.order_index = self.order_index
copied_step.type = self.type
copied_step.tool_id = self.tool_id
Expand Down Expand Up @@ -8238,10 +8238,10 @@ def copy_to(self, copied_step, step_mapping, user=None):
copied_step.subworkflow = subworkflow
copied_subworkflow = subworkflow
else:
# Can this even happen, building a workflow with a subworkflow you don't own ?
copied_subworkflow = subworkflow.copy()
# Importing a shared workflow with a subworkflow step
copied_subworkflow = subworkflow.copy(user=user)
stored_workflow = StoredWorkflow(
user, name=copied_subworkflow.name, workflow=copied_subworkflow, hidden=True
user=user, name=copied_subworkflow.name, workflow=copied_subworkflow, hidden=True
)
copied_subworkflow.stored_workflow = stored_workflow
copied_step.subworkflow = copied_subworkflow
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/base/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ def get_stored_workflow_steps(self, trans, stored_workflow: model.StoredWorkflow
except exceptions.ToolMissingException:
pass

def _import_shared_workflow(self, trans, stored):
def _import_shared_workflow(self, trans, stored: model.StoredWorkflow):
"""Imports a shared workflow"""
# Copy workflow.
imported_stored = model.StoredWorkflow()
Expand Down

0 comments on commit 3a195be

Please sign in to comment.