Skip to content

Commit 028c883

Browse files
authored
Fix packing for identifiers that are not in the index. (#610)
1 parent bee5a8b commit 028c883

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cwltool/pack.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ def loadref(b, u):
114114
# type: (Text, Text) -> Union[Dict, List, Text]
115115
return document_loader.resolve_ref(u, base_url=b)[0]
116116

117+
ids = set() # type: Set[Text]
118+
find_ids(processobj, ids)
119+
117120
runs = {uri}
118121
find_run(processobj, loadref, runs)
119122

120-
ids = set() # type: Set[Text]
121123
for f in runs:
122124
find_ids(document_loader.resolve_ref(f)[0], ids)
123125

@@ -134,8 +136,10 @@ def rewrite_id(r, mainuri):
134136
if r == mainuri:
135137
rewrite[r] = "#main"
136138
elif r.startswith(mainuri) and r[len(mainuri)] in ("#", "/"):
137-
path, frag = urllib.parse.urldefrag(r)
138-
rewrite[r] = "#"+frag
139+
if r[len(mainuri):].startswith("#main/"):
140+
rewrite[r] = "#" + uniquename(r[len(mainuri)+1:], names)
141+
else:
142+
rewrite[r] = "#" + uniquename("main/"+r[len(mainuri)+1:], names)
139143
else:
140144
path, frag = urllib.parse.urldefrag(r)
141145
if path == mainpath:
@@ -147,8 +151,7 @@ def rewrite_id(r, mainuri):
147151
sortedids = sorted(ids)
148152

149153
for r in sortedids:
150-
if r in document_loader.idx:
151-
rewrite_id(r, uri)
154+
rewrite_id(r, uri)
152155

153156
packed = {"$graph": [], "cwlVersion": metadata["cwlVersion"]
154157
} # type: Dict[Text, Any]

0 commit comments

Comments
 (0)