Skip to content

Commit 10f690a

Browse files
authored
Merge branch 'master' into rdf_python3_fix
2 parents cfca4bf + eefff3d commit 10f690a

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

cwltool/pack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,9 @@ def rewrite_id(r, mainuri):
157157

158158
import_embed(packed, set())
159159

160+
if len(packed["$graph"]) == 1:
161+
# duplicate 'cwlVersion' inside $graph when there is a single item
162+
# because we're printing contents inside '$graph' rather than whole dict
163+
packed["$graph"][0]["cwlVersion"] = packed["cwlVersion"]
164+
160165
return packed

tests/test_pack.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import partial
66

77
import cwltool.pack
8+
from cwltool.main import print_pack as print_pack
89
import cwltool.workflow
910
from cwltool.load_tool import fetch_document, validate_document
1011
from cwltool.main import makeRelative
@@ -33,3 +34,29 @@ def test_pack(self):
3334
del expect_packed["$schemas"]
3435

3536
self.assertEqual(expect_packed, packed)
37+
38+
def test_pack_missing_cwlVersion(self):
39+
"""Test to ensure the generated pack output is not missing
40+
the `cwlVersion` in case of single tool workflow and single step workflow"""
41+
# Since diff is longer than 3174 characters
42+
self.maxDiff = None
43+
44+
# Testing single tool workflow
45+
document_loader, workflowobj, uri = fetch_document(
46+
get_data("tests/wf/hello_single_tool.cwl"))
47+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
48+
document_loader, workflowobj, uri)
49+
# generate pack output dict
50+
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
51+
52+
self.assertEqual('v1.0', packed["cwlVersion"])
53+
54+
# Testing single step workflow
55+
document_loader, workflowobj, uri = fetch_document(
56+
get_data("tests/wf/hello-workflow.cwl"))
57+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
58+
document_loader, workflowobj, uri)
59+
# generate pack output dict
60+
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
61+
62+
self.assertEqual('v1.0', packed["cwlVersion"])

tests/wf/hello-workflow.cwl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.0
4+
class: Workflow
5+
6+
label: "Hello World"
7+
doc: "Outputs a message using echo"
8+
9+
inputs:
10+
usermessage: string
11+
12+
outputs:
13+
response:
14+
outputSource: step0/response
15+
type: File
16+
17+
steps:
18+
step0:
19+
run:
20+
class: CommandLineTool
21+
inputs:
22+
message:
23+
type: string
24+
doc: "The message to print"
25+
default: "Hello World"
26+
inputBinding:
27+
position: 1
28+
baseCommand: echo
29+
arguments:
30+
- "-n"
31+
- "-e"
32+
stdout: response.txt
33+
outputs:
34+
response:
35+
type: stdout
36+
in:
37+
message: usermessage
38+
out: [response]

tests/wf/hello_single_tool.cwl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand: echo
4+
inputs:
5+
message:
6+
type: string
7+
inputBinding:
8+
position: 1
9+
outputs: []

0 commit comments

Comments
 (0)