Skip to content

add size attribute to Files in the initial job object #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ test_script:

- "%CMD_IN_ENV% python setup.py test"

branches:
only:
- master
12 changes: 12 additions & 0 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,19 @@ def pathToLoc(p):
p["location"] = p["path"]
del p["path"]

def addSizes(p):
if 'location' in p:
try:
p["size"] = os.stat(p["location"][7:]).st_size # strip off file://
except OSError:
pass
elif 'contents' in p:
p["size"] = len(p['contents'])
else:
return # best effort

visit_class(job_order_object, ("File", "Directory"), pathToLoc)
visit_class(job_order_object, ("File"), addSizes)
adjustDirObjs(job_order_object, trim_listing)
normalizeFilesDirs(job_order_object)

Expand Down
2 changes: 1 addition & 1 deletion cwltool/pathmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def visit_class(rec, cls, op): # type: (Any, Iterable, Union[Callable[..., Any]
"""Apply a function to with "class" in cls."""

if isinstance(rec, dict):
if rec.get("class") in cls:
if "class" in rec and rec.get("class") in cls:
op(rec)
for d in rec:
visit_class(rec[d], cls, op)
Expand Down