Skip to content

Commit f342107

Browse files
committed
Add gxformat2 export
1 parent 8531562 commit f342107

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

bioblend/_tests/TestGalaxyWorkflows.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Any,
88
Dict,
99
List,
10+
Literal,
11+
Optional,
1012
)
1113

1214
import pytest
@@ -145,7 +147,7 @@ def test_import_publish_workflow_from_local_path(self):
145147
assert not imported_wf["deleted"]
146148
assert imported_wf["published"]
147149

148-
def test_import_export_workflow_dict(self):
150+
def _import_export(self, style: Optional[Literal["ga", "format2"]] = None):
149151
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))
150152
with open(path) as f:
151153
wf_dict = json.load(f)
@@ -155,8 +157,21 @@ def test_import_export_workflow_dict(self):
155157
assert imported_wf["url"].startswith("/api/workflows/")
156158
assert not imported_wf["deleted"]
157159
assert not imported_wf["published"]
158-
exported_wf_dict = self.gi.workflows.export_workflow_dict(imported_wf["id"])
160+
exported_wf_dict = self.gi.workflows.export_workflow_dict(imported_wf["id"], style=style)
159161
assert isinstance(exported_wf_dict, dict)
162+
if style == "format2":
163+
assert exported_wf_dict["class"] == "GalaxyWorkflow"
164+
else:
165+
assert exported_wf_dict["a_galaxy_workflow"] == "true"
166+
167+
def test_import_export_workflow_dict(self):
168+
self._import_export()
169+
170+
def test_import_export_workflow_dict_ga(self):
171+
self._import_export("ga")
172+
173+
def test_import_export_workflow_dict_format2(self):
174+
self._import_export("format2")
160175

161176
def test_import_publish_workflow_dict(self):
162177
path = test_util.get_abspath(os.path.join("data", "paste_columns.ga"))

bioblend/galaxy/workflows/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def __init__(self, galaxy_instance: "GalaxyInstance") -> None:
2929

3030
# the 'deleted' option is not available for workflows
3131
def get_workflows(
32-
self, workflow_id: Optional[str] = None, name: Optional[str] = None, published: bool = False
32+
self,
33+
workflow_id: Optional[str] = None,
34+
name: Optional[str] = None,
35+
published: bool = False,
36+
style: Optional[Literal["ga", "format2"]] = None,
3337
) -> List[Dict[str, Any]]:
3438
"""
3539
Get all workflows, or select a subset by specifying optional arguments
@@ -41,6 +45,9 @@ def get_workflows(
4145
:type published: bool
4246
:param published: if ``True``, return also published workflows
4347
48+
:type style
49+
:param style: Set style to `format2` to get gxformat2 encoded workflow
50+
4451
:rtype: list
4552
:return: A list of workflow dicts.
4653
For example::
@@ -60,6 +67,8 @@ def get_workflows(
6067
params: Dict[str, Any] = {}
6168
if published:
6269
params["show_published"] = True
70+
if style:
71+
params["style"] = style
6372
workflows = self._get(params=params)
6473
if name is not None:
6574
workflows = [_ for _ in workflows if _["name"] == name]

0 commit comments

Comments
 (0)