Skip to content

Commit

Permalink
--print-targets: support embedded step processess
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Nov 7, 2021
1 parent 2b9d7b0 commit b807e39
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,11 @@ def print_targets(
_logger.info("%s steps targets:", prefix[:-1])
for t in tool.tool["steps"]:
stdout.write(f" {prefix}{shortname(t['id'])}\n")
run: Union[str, Process] = t["run"]
run: Union[str, Process, Dict[str, Any]] = t["run"]
if isinstance(run, str):
process = make_tool(run, loading_context)
elif isinstance(run, dict):
process = make_tool(cast(CommentedMap, cmap(run)), loading_context)
else:
process = run
print_targets(process, stdout, loading_context, shortname(t["id"]) + "/")
Expand Down
49 changes: 49 additions & 0 deletions tests/subgraph/timelimit2-wf.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env cwl-runner
class: Workflow
cwlVersion: v1.2

requirements:
ToolTimeLimit:
timelimit: 5
InlineJavascriptRequirement: {}

inputs:
i:
type: string?

outputs:
o:
type: string?
outputSource: step2/o

steps:
step1:
in:
i: i
out: [o]
run:
class: CommandLineTool
baseCommand: ["sleep", "3"]
inputs:
i:
type: string?
outputs:
o:
type: string?
outputBinding:
outputEval: $("time passed")
step2:
in:
i: step1/o
out: [o]
run:
class: CommandLineTool
baseCommand: ["sleep", "3"]
inputs:
i:
type: string?
outputs:
o:
type: string?
outputBinding:
outputEval: $("time passed")
11 changes: 11 additions & 0 deletions tests/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,14 @@ def test_single_step_packed_subwf_step() -> None:
json.loads(stdout)["out"]["checksum"]
== "sha1$7608e5669ba454c61fab01c9b133b52a9a7de68c"
)


def test_print_targets_embedded_step() -> None:
"""Confirm that --print-targets works when a Workflow has embedded Processes."""
err_code, stdout, stderr = get_main_output(
[
"--print-targets",
get_data("tests/subgraph/timelimit2-wf.cwl"),
]
)
assert err_code == 0

0 comments on commit b807e39

Please sign in to comment.