10000 Merge branch 'improve-workflow' · illusional/python-cwlgen@e539108 · GitHub
[go: up one dir, main page]

Skip to content

Commit e539108

Browse files
committed
Merge branch 'improve-workflow'
2 parents 650752a + c8b08b1 commit e539108

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

cwlgen/workflow.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,32 @@
2525

2626
# Function(s) ------------------------------
2727

28-
def parse_scatter_method(scatter_method):
29-
if scatter_method is not None and scatter_method not in SCATTER_METHODS:
30-
raise ValueError("The scatter method '{method}' is not a valid ScatterMethod, expected one of: {expected}"
28+
def parse_scatter_method(scatter_method, required=False):
29+
if scatter_method is None and not required:
30+
return None
31+
elif scatter_method not in SCATTER_METHODS:
32+
if required:
33+
raise Exception("The scatter method '{method}' is not a valid ScatterMethod and requires one of: {expected}"
34+
.format(method=scatter_method, expected=" ,".join(SCATTER_METHODS)))
35+
elif scatter_method is not None:
36+
_LOGGER.info("The scatter method '{method}' is not a valid ScatterMethod, expected one of: {expected}"
3137
.format(method=scatter_method, expected=" ,".join(SCATTER_METHODS)))
38+
return None
3239
return scatter_method
3340

3441

35-
def parse_link_merge_method(link_merge):
36-
if link_merge not in LINK_MERGE_METHODS:
37-
_LOGGER.warning("The link merge method '{method}' is not a valid LinkMergeMethod, expected one of: {expected}. "
38-
"This value will be null which CWL defaults to 'merge_nested'"
39-
.format(method=link_merge, expected=" ,".join(LINK_MERGE_METHODS)))
42+
def parse_link_merge_method(link_merge, required=False):
43+
if link_merge is None and not required:
4044
return None
45+
elif link_merge not in LINK_MERGE_METHODS:
46+
if required:
47+
raise Exception("The link merge method '{method}' is not a valid LinkMergeMethod and requires one of:"
48+
" {expected}. ".format(method=link_merge, expected=" ,".join(LINK_MERGE_METHODS)))
49+
elif link_merge is not None:
50+
_LOGGER.info("The link merge method '{method}' is not a valid LinkMergeMethod, expected one of:"
51+
" {expected}. This value will be null which CWL defaults to 'merge_nested'"
52+
.format(method=link_merge, expected=" ,".join(LINK_MERGE_METHODS)))
53+
return None
4154
return link_merge
4255

4356

@@ -90,13 +103,8 @@ def get_dict(self):
90103
cwl_workflow['inputs'] = {i.id: i.get_dict() for i in self.inputs}
91104
cwl_workflow['outputs'] = {o.id: o.get_dict() for o in self.outputs}
92105

93-
# Add requirements.
94-
requirements = {}
95-
for requirement in self.requirements:
96-
requirement.add(requirements)
97-
98-
if requirements:
99-
cwl_workflow['requirements'] = requirements
106+
if self.requirements:
107+
cwl_workflow['requirements'] = {r.req_class: r.get_dict() for r in self.requirements}
100108

101109
if self.hints:
102110
# can be array<Any> | dict<class, Any>
@@ -219,7 +227,7 @@ def get_dict(self):
219227
workflow_step = {k: v for k, v in vars(self).items() if v is not None and type(v) is str}
220228

221229
workflow_step['in'] = {i.id: i.get_dict() for i in self.inputs}
222-
workflow_step['out'] = {o.id: o.get_dict() for o in self.out}
230+
workflow_step['out'] = [o.id for o in self.out]
223231

224232
if isinstance(self.run, six.string_types):
225233
workflow_step['run'] = self.run

0 commit comments

Comments
 (0)
0