Skip to content

Commit

Permalink
debugging upload script
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Feb 9, 2024
1 parent aa0ffd3 commit e4e6d59
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xnat_ingest/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def xnat_session_exists(project_id, subject_id, session_id):
session_objs[session_ids].append((path_parts[3:-1], obj))

session_objs = {
(ids, objs)
ids: objs
for ids, objs in session_objs.items()
if not xnat_session_exists(*ids)
}
Expand All @@ -190,7 +190,10 @@ def iter_staged_sessions():
session_tmp_dir = tmp_download_dir.joinpath(*ids)
session_tmp_dir.mkdir(parents=True, exist_ok=True)
for relpath, obj in objs:
with open(session_tmp_dir.joinpath(relpath), "wb") as f:
obj_path = session_tmp_dir.joinpath(*relpath)
obj_path.parent.mkdir(parents=True, exist_ok=True)
with open(obj_path, "wb") as f:
logger.debug("Downloading %s to %s", obj, obj_path)
bucket.download_fileobj(obj.key, f)
yield session_tmp_dir
shutil.rmtree(
Expand Down Expand Up @@ -357,5 +360,3 @@ def iter_staged_sessions():
continue
else:
raise

shutil.rmtree(tmp_download_dir)

0 comments on commit e4e6d59

Please sign in to comment.