From cc8eff0835fe16d0458cc50a05395c9394d45ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= <38459088+jo-mueller@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:57:08 +0100 Subject: [PATCH 1/2] added export action --- napari_pyclesperanto_assistant/_gui/_Assistant.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/napari_pyclesperanto_assistant/_gui/_Assistant.py b/napari_pyclesperanto_assistant/_gui/_Assistant.py index 8b2df2d..1290bdf 100644 --- a/napari_pyclesperanto_assistant/_gui/_Assistant.py +++ b/napari_pyclesperanto_assistant/_gui/_Assistant.py @@ -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 @@ -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 ...", ".", "*.wfl") + + # get the workflow, should one be installed + workflow_manager = WorkflowManager.install(self._viewer) + _io_yaml_v1.save_workflow(filename, workflow_manager.workflow) From fef0826caa8b792ccc9f7917fa92f314a399de60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= <38459088+jo-mueller@users.noreply.github.com> Date: Fri, 4 Feb 2022 15:03:40 +0100 Subject: [PATCH 2/2] changed file ending to yaml --- napari_pyclesperanto_assistant/_gui/_Assistant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napari_pyclesperanto_assistant/_gui/_Assistant.py b/napari_pyclesperanto_assistant/_gui/_Assistant.py index 1290bdf..21aa998 100644 --- a/napari_pyclesperanto_assistant/_gui/_Assistant.py +++ b/napari_pyclesperanto_assistant/_gui/_Assistant.py @@ -296,7 +296,7 @@ def to_file(self, filename=None): from napari_workflows import WorkflowManager, _io_yaml_v1 if not filename: - filename, _ = QFileDialog.getSaveFileName(self, "Export workflow ...", ".", "*.wfl") + filename, _ = QFileDialog.getSaveFileName(self, "Export workflow ...", ".", "*.yaml") # get the workflow, should one be installed workflow_manager = WorkflowManager.install(self._viewer)