Skip to content

Commit 2c43c85

Browse files
huzechmr-c
andauthored
fix --single-step step2_tool error (#1597)
when use --single-step step2_tool parameter to run step in workflow meet this error Traceback (most recent call last): File "/d/project/cwltool-main/cwltool/main.py", line 1181, in main ctool = choose_step(args, tool, loadingContext) File "/d/project/cwltool-main/cwltool/main.py", line 861, in choose_step extracted = get_step(tool, step_id, loading_context) File "/d/project/cwltool-main/cwltool/subgraph.py", line 225, in get_step name = outport.split("#")[-1].split("/")[-1] AttributeError: 'CommentedMap' object has no attribute 'split' Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 318876b commit 2c43c85

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

cwltool/subgraph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,12 @@ def get_step(
221221
if "linkMerge" in inport:
222222
del inport["linkMerge"]
223223

224-
for outport in cast(List[str], step["out"]):
225-
name = outport.split("#")[-1].split("/")[-1]
224+
for outport in cast(List[Union[str, Mapping[str, Any]]], step["out"]):
225+
if isinstance(outport, Mapping):
226+
outport_id = cast(str, outport["id"])
227+
else:
228+
outport_id = outport
229+
name = outport_id.split("#")[-1].split("/")[-1]
226230
extracted["outputs"].append(
227231
{
228232
"id": name,

tests/subgraph/env-wf2_long.cwl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.2
4+
5+
inputs:
6+
in: string
7+
8+
outputs:
9+
out:
10+
type: File
11+
outputSource: step1/out
12+
13+
requirements:
14+
EnvVarRequirement:
15+
envDef:
16+
TEST_ENV: override
17+
18+
steps:
19+
step1:
20+
run: env-tool2.cwl
21+
in:
22+
in: in
23+
out:
24+
- id: out

tests/subgraph/env-wf2_subwf_b.cwl

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.2
4+
5+
inputs:
6+
in: string
7+
8+
outputs:
9+
out:
10+
type: File
11+
outputSource: sub_wf/out
12+
13+
requirements:
14+
SubworkflowFeatureRequirement: {}
15+
EnvVarRequirement:
16+
envDef:
17+
TEST_ENV: override_super
18+
19+
steps:
20+
sub_wf:
21+
run: env-wf2_long.cwl
22+
in:
23+
in: in
24+
out: [out]

tests/test_subgraph.py

+17
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ def test_single_step_subwf_step() -> None:
241241
)
242242

243243

244+
def test_single_step_wfstep_long_out() -> None:
245+
"""Support long form of step.out with --single-step."""
246+
err_code, stdout, stderr = get_main_output(
247+
[
248+
"--single-step",
249+
"sub_wf/step1",
250+
get_data("tests/subgraph/env-wf2_subwf_b.cwl"),
251+
get_data("tests/subgraph/env-job.json"),
252+
]
253+
)
254+
assert err_code == 0
255+
assert (
256+
json.loads(stdout)["out"]["checksum"]
257+
== "sha1$7608e5669ba454c61fab01c9b133b52a9a7de68c"
258+
)
259+
260+
244261
def test_single_step_packed_subwf_step() -> None:
245262
"""Inherit reqs and hints --single-step on packed sub-workflow step."""
246263
err_code, stdout, stderr = get_main_output(

0 commit comments

Comments
 (0)