Skip to content

Commit edd26e0

Browse files
authored
Fix packing when files are in multiple directories. (#271)
* Fix packing when files are in multiple directories. * Ensure that repacked ids are unique. * Sort run step identifiers for stable id renaming. * Fix regression in --print-deps calculating relative directories.
1 parent ce7b604 commit edd26e0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

cwltool/main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def makeRelative(base, ob):
499499
else:
500500
if u.startswith("file://"):
501501
u = uri_file_path(u)
502-
ob["location"] = os.path.relpath(u, base)
502+
ob["location"] = os.path.relpath(u, base)
503503

504504
def printdeps(obj, document_loader, stdout, relative_deps, uri, basedir=None):
505505
# type: (Dict[Text, Any], Loader, IO[Any], bool, Text, Text) -> None
@@ -517,9 +517,9 @@ def loadref(b, u):
517517

518518
if relative_deps:
519519
if relative_deps == "primary":
520-
base = basedir if basedir else os.path.dirname(uri)
520+
base = basedir if basedir else os.path.dirname(uri_file_path(str(uri)))
521521
elif relative_deps == "cwd":
522-
base = file_uri(os.getcwd())
522+
base = os.getcwd()
523523
else:
524524
raise Exception(u"Unknown relative_deps %s" % relative_deps)
525525

cwltool/pack.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from schema_salad.ref_resolver import Loader
55

6-
from .process import scandeps, shortname
6+
from .process import scandeps, shortname, uniquename
77

88
from typing import Union, Any, cast, Callable, Dict, Tuple, Type, IO, Text
99

@@ -12,9 +12,12 @@ def flatten_deps(d, files): # type: (Any, Set[Text]) -> None
1212
for s in d:
1313
flatten_deps(s, files)
1414
elif isinstance(d, dict):
15-
files.add(d["location"])
15+
if d["class"] == "File":
16+
files.add(d["location"])
1617
if "secondaryFiles" in d:
1718
flatten_deps(d["secondaryFiles"], files)
19+
if "listing" in d:
20+
flatten_deps(d["listing"], files)
1821

1922
def find_run(d, runs): # type: (Any, Set[Text]) -> None
2023
if isinstance(d, list):
@@ -59,12 +62,12 @@ def loadref(b, u):
5962
rewrite = {}
6063
if isinstance(processobj, list):
6164
for p in processobj:
62-
rewrite[p["id"]] = "#" + shortname(p["id"])
65+
rewrite[p["id"]] = "#" + uniquename(shortname(p["id"]))
6366
else:
6467
rewrite[uri] = "#main"
6568

66-
for r in runs:
67-
rewrite[r] = "#" + shortname(r)
69+
for r in sorted(runs):
70+
rewrite[r] = "#" + uniquename(shortname(r))
6871

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

0 commit comments

Comments
 (0)