diff --git a/cwltool/main.py b/cwltool/main.py index 6d4f9e3b8..3e2b7b46c 100755 --- a/cwltool/main.py +++ b/cwltool/main.py @@ -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"]) + "/") diff --git a/tests/subgraph/timelimit2-wf.cwl b/tests/subgraph/timelimit2-wf.cwl new file mode 100644 index 000000000..9abafe5c8 --- /dev/null +++ b/tests/subgraph/timelimit2-wf.cwl @@ -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") diff --git a/tests/test_subgraph.py b/tests/test_subgraph.py index 5c7fd1069..cd19e9e1c 100644 --- a/tests/test_subgraph.py +++ b/tests/test_subgraph.py @@ -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