Skip to content

Commit c7734d3

Browse files
committed
add size attribute to Files in the initial job object
1 parent f84ff04 commit c7734d3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ test_script:
2626

2727
- "%CMD_IN_ENV% python setup.py test"
2828

29+
branches:
30+
only:
31+
- master

cwltool/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,14 @@ def pathToLoc(p):
591591
p["location"] = p["path"]
592592
del p["path"]
593593

594+
def addSizes(p):
595+
try:
596+
p["size"] = os.stat(p["location"][7:]).st_size # strip off file://
597+
except OSError:
598+
return # best effort
599+
594600
visit_class(job_order_object, ("File", "Directory"), pathToLoc)
601+
visit_class(job_order_object, ("File"), addSizes)
595602
adjustDirObjs(job_order_object, trim_listing)
596603
normalizeFilesDirs(job_order_object)
597604

cwltool/pathmapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def visit_class(rec, cls, op): # type: (Any, Iterable, Union[Callable[..., Any]
3737
"""Apply a function to with "class" in cls."""
3838

3939
if isinstance(rec, dict):
40-
if rec.get("class") in cls:
40+
if "class" in rec and rec.get("class") in cls:
4141
op(rec)
4242
for d in rec:
4343
visit_class(rec[d], cls, op)

0 commit comments

Comments
 (0)