Skip to content

Commit

Permalink
Merge pull request #19525 from mvdbeek/fix_extracting_workflow_from_p…
Browse files Browse the repository at this point in the history
…urged_histories

[24.1] Fix extracting workflows from purged and deleted histories
  • Loading branch information
mvdbeek authored Feb 4, 2025
2 parents 94456cb + bd42a47 commit e7e348a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3645,6 +3645,10 @@ def active_contents(self):
"""Return all active contents ordered by hid."""
return self.contents_iter(types=["dataset", "dataset_collection"], deleted=False, visible=True)

@property
def visible_contents(self):
return self.contents_iter(types=["dataset", "dataset_collection"], visible=True)

def contents_iter(self, **kwds):
"""
Fetch filtered list of contents of history.
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/workflow/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __summarize(self):
# just grab the implicitly mapped jobs and handle in second pass. Second pass is
# needed because cannot allow selection of individual datasets from an implicit
# mapping during extraction - you get the collection or nothing.
for content in self.history.active_contents:
for content in self.history.visible_contents:
self.__summarize_content(content)

def __summarize_content(self, content):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ into a workflow will be shown in gray.</p>
<div class="warningmark">${warning}</div>
%endfor

<form method="post" action="${h.url_for(controller='workflow', action='build_from_current_history')}">
<form method="post" action="${h.url_for(controller='workflow', action='build_from_current_history', history_id=trans.security.encode_id(history.id))}">
<div class='form-row'>
<label>Workflow name</label>
<input name="workflow_name" type="text" value="Workflow constructed from history '${ util.unicodify( history.name )}'" size="60"/>
Expand All @@ -112,6 +112,7 @@ into a workflow will be shown in gray.</p>
<%
cls = "toolForm"
tool_name = "Unknown"
checked_job = "checked" if any(True for d in datasets if not d[1].deleted) else ""
if hasattr( job, 'is_fake' ) and job.is_fake:
cls += " toolFormDisabled"
disabled = True
Expand Down Expand Up @@ -142,7 +143,10 @@ into a workflow will be shown in gray.</p>
%if disabled:
<div style="font-style: italic; color: gray">${disabled_why}</div>
%else:
<div><input type="checkbox" name="job_ids" value="${job.id}" checked="true" />Include "${tool_name}" in workflow</div>
<div><input type="checkbox" name="job_ids" value="${job.id}" ${checked_job} />Include "${tool_name}" in workflow</div>
%if not checked_job:
${ render_msg( "All job outputs have been deleted", status="info" ) }
%endif
%if tool_version_warning:
${ render_msg( tool_version_warning, status="warning" ) }
%endif
Expand Down
4 changes: 4 additions & 0 deletions test/unit/workflows/test_extract_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def __init__(self):
def active_contents(self):
return self.active_datasets

@property
def visible_contents(self):
return self.active_contents


class MockTrans:
def __init__(self, history):
Expand Down

0 comments on commit e7e348a

Please sign in to comment.