Skip to content

Commit

Permalink
Support extract workflow from any history in client controller
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 27, 2024
1 parent 0b4c0b2 commit a9de122
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function userTitle(title: string) {
<BDropdownItem
:disabled="isAnonymous"
:title="userTitle('Convert History to Workflow')"
@click="iframeRedirect('/workflow/build_from_current_history')">
@click="iframeRedirect(`/workflow/build_from_current_history?history_id=${history.id}`)">
<FontAwesomeIcon fixed-width :icon="faFileExport" class="mr-1" />
<span v-localize>Extract Workflow</span>
</BDropdownItem>
Expand Down
16 changes: 14 additions & 2 deletions lib/galaxy/webapps/galaxy/controllers/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
util,
web,
)
from galaxy.managers.histories import HistoryManager
from galaxy.managers.sharable import SlugBuilder
from galaxy.model.item_attrs import UsesItemRatings
from galaxy.structured_app import StructuredApp
from galaxy.tools.parameters.workflow_utils import workflow_building_modes
from galaxy.util import FILENAME_VALID_CHARS
from galaxy.web import url_for
Expand All @@ -24,13 +26,18 @@
summarize,
)
from galaxy.workflow.modules import load_module_sections
from ..api import depends

log = logging.getLogger(__name__)


class WorkflowController(BaseUIController, SharableMixin, UsesStoredWorkflowMixin, UsesItemRatings):
history_manager: HistoryManager = depends(HistoryManager)
slug_builder = SlugBuilder()

def __init__(self, app: StructuredApp):
super().__init__(app)

@web.expose
def display_by_username_and_slug(self, trans, username, slug, format="html", **kwargs):
"""
Expand Down Expand Up @@ -304,14 +311,18 @@ def build_from_current_history(
workflow_name=None,
dataset_names=None,
dataset_collection_names=None,
history_id=None,
**kwargs,
):
user = trans.get_user()
history = trans.get_history()
history = trans.history
if history_id:
# Optionally target a different history than the current one.
history = self.history_manager.get_owned(self.decode_id(history_id), trans.user, current_history=history)
if not user:
return trans.show_error_message("Must be logged in to create workflows")
if (job_ids is None and dataset_ids is None) or workflow_name is None:
jobs, warnings = summarize(trans)
jobs, warnings = summarize(trans, history)
# Render
return trans.fill_template(
"workflow/build_from_current_history.mako", jobs=jobs, warnings=warnings, history=history
Expand All @@ -324,6 +335,7 @@ def build_from_current_history(
stored_workflow = extract_workflow(
trans,
user=user,
history=history,
job_ids=job_ids,
dataset_ids=dataset_ids,
dataset_collection_ids=dataset_collection_ids,
Expand Down

0 comments on commit a9de122

Please sign in to comment.