Skip to content

Commit ff7bec3

Browse files
committed
2 parents c02569a + 3ddc89c commit ff7bec3

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

cwltool/cwltest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def run_test(args, i, t):
131131

132132

133133
def main():
134-
parser = argparse.ArgumentParser()
134+
parser = argparse.ArgumentParser(description='Compliance tests for cwltool')
135135
parser.add_argument("--test", type=str, help="YAML file describing test cases", required=True)
136136
parser.add_argument("--basedir", type=str, help="Basedir to use for tests", default=".")
137137
parser.add_argument("-n", type=int, default=None, help="Run a specific test")

cwltool/main.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
_logger.setLevel(logging.INFO)
3030

3131
def arg_parser():
32-
parser = argparse.ArgumentParser()
32+
parser = argparse.ArgumentParser(description='Reference executor for Common Workflow Language')
3333
parser.add_argument("--conformance-test", action="store_true")
3434
parser.add_argument("--basedir", type=str)
3535
parser.add_argument("--outdir", type=str, default=os.path.abspath('.'),
@@ -99,6 +99,7 @@ def arg_parser():
9999
help="Print corresponding RDF graph for workflow and exit")
100100
exgroup.add_argument("--print-dot", action="store_true", help="Print workflow visualization in graphviz format and exit")
101101
exgroup.add_argument("--print-pre", action="store_true", help="Print CWL document after preprocessing.")
102+
exgroup.add_argument("--print-deps", action="store_true", help="Print CWL document dependencies from $import, $include, $schemas")
102103
exgroup.add_argument("--version", action="store_true", help="Print version and exit")
103104
exgroup.add_argument("--update", action="store_true", help="Update to latest CWL version, print and exit")
104105

@@ -412,6 +413,42 @@ def load_job_order(args, t, parser):
412413
return (job_order_object, input_basedir)
413414

414415

416+
def scandeps(base, doc):
417+
r = []
418+
if isinstance(doc, dict):
419+
if "$import" in doc:
420+
p = os.path.join(base, doc["$import"])
421+
with open(p) as f:
422+
r.append({
423+
"class": "File",
424+
"path": p,
425+
"secondaryFiles": scandeps(os.path.dirname(p), yaml.load(f))
426+
})
427+
elif "$include" in doc:
428+
p = os.path.join(base, doc["$include"])
429+
r.append({
430+
"class": "File",
431+
"path": p
432+
})
433+
elif "$schemas" in doc:
434+
for s in doc["$schemas"]:
435+
p = os.path.join(base, s)
436+
r.append({
437+
"class": "File",
438+
"path": p
439+
})
440+
else:
441+
for d in doc.itervalues():
442+
r.extend(scandeps(base, d))
443+
elif isinstance(doc, list):
444+
for d in doc:
445+
r.extend(scandeps(base, d))
446+
return r
447+
448+
def print_deps(fn):
449+
with open(fn) as f:
450+
print json.dumps(scandeps(os.path.dirname(fn), yaml.load(f)), indent=4)
451+
415452
def main(args=None,
416453
executor=single_job_executor,
417454
makeTool=workflow.defaultMakeTool,
@@ -451,6 +488,10 @@ def main(args=None,
451488
_logger.error("CWL document required")
452489
return 1
453490

491+
if args.print_deps:
492+
print_deps(args.workflow)
493+
return 0
494+
454495
try:
455496
t = load_tool(args.workflow, args.update, args.strict, makeTool, args.debug,
456497
print_pre=args.print_pre,

0 commit comments

Comments
 (0)