Skip to content

Commit 665141f

Browse files
author
Peter Amstutz
authored
Tweak packing and scandeps (#1167)
1) allows result from pack() to be re-run back through resolve_all 2) scandeps no longer adds dependencies for same-file cross references.
1 parent 8010fd2 commit 665141f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cwltool/pack.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ruamel.yaml.comments import CommentedMap, CommentedSeq
99
from schema_salad.ref_resolver import Loader # pylint: disable=unused-import
1010
from schema_salad.ref_resolver import SubLoader
11+
from schema_salad.sourceline import cmap
1112
from six import iteritems, string_types
1213
from six.moves import urllib
1314
from typing_extensions import Text # pylint: disable=unused-import
@@ -170,8 +171,8 @@ def rewrite_id(r, mainuri):
170171
for r in sortedids:
171172
rewrite_id(r, uri)
172173

173-
packed = {"$graph": [], "cwlVersion": metadata["cwlVersion"]
174-
} # type: Dict[Text, Any]
174+
packed = CommentedMap((("$graph", CommentedSeq()),
175+
("cwlVersion", metadata["cwlVersion"])))
175176
namespaces = metadata.get('$namespaces', None)
176177

177178
schemas = set() # type: Set[Text]
@@ -217,6 +218,6 @@ def rewrite_id(r, mainuri):
217218
packed["$graph"][0]["$schemas"] = list(schemas)
218219
# always include $namespaces in the #main
219220
if namespaces:
220-
packed["$graph"][0]["$namespaces"] = dict(cast(Dict, namespaces))
221+
packed["$graph"][0]["$namespaces"] = cmap(namespaces)
221222

222223
return packed

cwltool/process.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,12 @@ def scandeps(base, # type: Text
982982
base, u, reffields, urlfields, loadref,
983983
urljoin=urljoin, nestdirs=nestdirs))
984984
else:
985-
sub = loadref(base, u)
986985
subid = urljoin(base, u)
986+
basedf, _ = urllib.parse.urldefrag(base)
987+
subiddf, _ = urllib.parse.urldefrag(subid)
988+
if basedf == subiddf:
989+
continue
990+
sub = loadref(base, u)
987991
deps = {
988992
"class": "File",
989993
"location": subid,

0 commit comments

Comments
 (0)