Skip to content

Commit 6618eb1

Browse files
author
Anton Khodak
committed
Preserve namespaces after packing
* fix #584
1 parent 5adb3fb commit 6618eb1

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

cwltool/pack.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def rewrite_id(r, mainuri):
149149

150150
packed = {"$graph": [], "cwlVersion": metadata["cwlVersion"]
151151
} # type: Dict[Text, Any]
152+
namespaces = metadata.get('$namespaces')
152153

153154
schemas = set() # type: Set[Text]
154155
for r in sorted(runs):
@@ -185,5 +186,7 @@ def rewrite_id(r, mainuri):
185186
# duplicate 'cwlVersion' inside $graph when there is a single item
186187
# because we're printing contents inside '$graph' rather than whole dict
187188
packed["$graph"][0]["cwlVersion"] = packed["cwlVersion"]
189+
if namespaces:
190+
packed["$graph"][0]["$namespaces"] = dict(namespaces)
188191

189192
return packed

tests/test_pack.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,15 @@ def test_packed_workflow_execution(self):
116116
stdout=normal_output), 0)
117117
self.assertEquals(json.loads(packed_output.getvalue()), json.loads(normal_output.getvalue()))
118118

119+
@pytest.mark.skipif(onWindows(),
120+
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
121+
"which is not supported on AppVeyor")
122+
def test_preserving_namespaces(self):
123+
test_wf = "tests/wf/formattest.cwl"
124+
document_loader, workflowobj, uri = fetch_document(
125+
get_data(test_wf))
126+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
127+
document_loader, workflowobj, uri)
128+
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
129+
assert "$namespaces" in packed
130+

tests/wf/formattest.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
$namespaces:
2+
edam: "http://edamontology.org/"
3+
cwlVersion: v1.0
4+
class: CommandLineTool
5+
doc: "Reverse each line using the `rev` command"
6+
inputs:
7+
input:
8+
type: File
9+
inputBinding: {}
10+
format: edam:format_2330
11+
12+
outputs:
13+
output:
14+
type: File
15+
outputBinding:
16+
glob: output.txt
17+
format: edam:format_2330
18+
19+
baseCommand: rev
20+
stdout: output.txt

0 commit comments

Comments
 (0)