Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit a313c23

Browse files
authored
Merge pull request #6 from bmeg/run-expand
Making workflow step run field expansion something that can be turned off
2 parents 812d1cf + 6c72cc5 commit a313c23

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Diff for: cwlgen/import_cwl.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def parse_cwl(cwl_path):
3030
p = CWLToolParser()
3131
return p.import_cwl(cwl_path)
3232
if cl == "Workflow":
33-
p = CWLToolParser()
33+
p = CWLWorkflowParser()
3434
return p.import_cwl(cwl_path)
3535
return None
3636

@@ -595,8 +595,9 @@ class StepsParser(object):
595595
"""
596596
Class to parse content of steps of workflow from existing CWL Workflow.
597597
"""
598-
def __init__(self, basedir=None):
598+
def __init__(self, basedir=None, expand_run=True):
599599
self.basedir = basedir
600+
self.expand_run = expand_run
600601

601602
def _load_in(self, step_obj, in_el):
602603
for key, val in in_el.items():
@@ -613,10 +614,12 @@ def _load_out(self, step_obj, in_el):
613614
step_obj.outputs.append(o)
614615

615616
def _load_run(self, step_obj, in_el):
616-
if isinstance(in_el, basestring):
617+
if isinstance(in_el, basestring) and self.expand_run:
617618
path = os.path.join(self.basedir, in_el)
618619
#logger.info("Parsing: %s", path)
619620
step_obj.run = parse_cwl(path)
621+
else:
622+
step_obj.run = in_el
620623

621624

622625
def load_steps(self, steps_obj, steps_elm):
@@ -640,8 +643,9 @@ def load_steps(self, steps_obj, steps_elm):
640643

641644
class CWLWorkflowParser(object):
642645

643-
def __init__(self, basedir=None):
646+
def __init__(self, basedir=None, expand_run=True):
644647
self.basedir = basedir
648+
self.expand_run = expand_run
645649

646650
def _init_workflow(self, cwl_dict):
647651
"""
@@ -744,5 +748,5 @@ def _load_steps(self, tool, outputs_el):
744748
:param outputs_el: Content of outputs
745749
:type outputs_el: LIST or DICT
746750
"""
747-
inp_parser = StepsParser(self.basedir)
751+
inp_parser = StepsParser(self.basedir, self.expand_run)
748752
inp_parser.load_steps(tool.steps, outputs_el)

Diff for: cwlgen/workflow.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def get_dict(self):
9898
if self.outputs:
9999
dict_param['out'] = []
100100
for i in self.outputs:
101-
dict_param['out'].append(i)
101+
if isinstance(i, WorkflowStepOutput):
102+
dict_param['out'].append(i.id)
103+
else:
104+
dict_param['out'].append(i)
102105

103106
return dict_param
104107

0 commit comments

Comments
 (0)