Skip to content

Commit

Permalink
Merge pull request #44 from jo-mueller/add-workflow-export
Browse files Browse the repository at this point in the history
Add workflow export
  • Loading branch information
haesleinhuepf authored Feb 4, 2022
2 parents b7d30a6 + fef0826 commit 66f69e5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions napari_pyclesperanto_assistant/_gui/_Assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def text_changed(*args, **kwargs):
("Export Python script to file", self.to_jython),
("Export Jupyter Notebook", self.to_notebook),
("Copy to clipboard", self.to_clipboard),
("Export workflow to file", self.to_file)
]

# add Send to script editor menu in case it's installed
Expand Down Expand Up @@ -290,3 +291,13 @@ def to_script_editor(self):
import napari_script_editor
editor = napari_script_editor.ScriptEditor.get_script_editor_from_viewer(self._viewer)
editor.set_code(Pipeline.from_assistant(self).to_napari_python())

def to_file(self, filename=None):
from napari_workflows import WorkflowManager, _io_yaml_v1

if not filename:
filename, _ = QFileDialog.getSaveFileName(self, "Export workflow ...", ".", "*.yaml")

# get the workflow, should one be installed
workflow_manager = WorkflowManager.install(self._viewer)
_io_yaml_v1.save_workflow(filename, workflow_manager.workflow)

0 comments on commit 66f69e5

Please sign in to comment.