|
29 | 29 | _logger.setLevel(logging.INFO)
|
30 | 30 |
|
31 | 31 | def arg_parser():
|
32 |
| - parser = argparse.ArgumentParser() |
| 32 | + parser = argparse.ArgumentParser(description='Reference executor for Common Workflow Language') |
33 | 33 | parser.add_argument("--conformance-test", action="store_true")
|
34 | 34 | parser.add_argument("--basedir", type=str)
|
35 | 35 | parser.add_argument("--outdir", type=str, default=os.path.abspath('.'),
|
@@ -99,6 +99,7 @@ def arg_parser():
|
99 | 99 | help="Print corresponding RDF graph for workflow and exit")
|
100 | 100 | exgroup.add_argument("--print-dot", action="store_true", help="Print workflow visualization in graphviz format and exit")
|
101 | 101 | 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") |
102 | 103 | exgroup.add_argument("--version", action="store_true", help="Print version and exit")
|
103 | 104 | exgroup.add_argument("--update", action="store_true", help="Update to latest CWL version, print and exit")
|
104 | 105 |
|
@@ -412,6 +413,42 @@ def load_job_order(args, t, parser):
|
412 | 413 | return (job_order_object, input_basedir)
|
413 | 414 |
|
414 | 415 |
|
| 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 | + |
415 | 452 | def main(args=None,
|
416 | 453 | executor=single_job_executor,
|
417 | 454 | makeTool=workflow.defaultMakeTool,
|
@@ -451,6 +488,10 @@ def main(args=None,
|
451 | 488 | _logger.error("CWL document required")
|
452 | 489 | return 1
|
453 | 490 |
|
| 491 | + if args.print_deps: |
| 492 | + print_deps(args.workflow) |
| 493 | + return 0 |
| 494 | + |
454 | 495 | try:
|
455 | 496 | t = load_tool(args.workflow, args.update, args.strict, makeTool, args.debug,
|
456 | 497 | print_pre=args.print_pre,
|
|
0 commit comments