Skip to content
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

ENH: upload: --existing=overwrite-metadata to upload fresh metadata even if file already there #355

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ENH: upload - DANDI_UPLOAD_SAME_MUST_EXIST for internal use for paran…
…oids
  • Loading branch information
yarikoptic committed Feb 2, 2021
commit c072c2a739a07052f02a0c3c9889d5a4f432137c
3 changes: 3 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ development command line options.
new set on each run. Set this environment variable to `0` to cause the
containers to be destroyed at the end of the next run.

- `DANDI_UPLOAD_SAME_MUST_EXIST` -- primarily for internal use with
`--existing=overwrite-metadata` so we do not upload some outdated file.

## Sourcegraph

The [Sourcegraph](https://sourcegraph.com) browser extension can be used to
Expand Down
13 changes: 13 additions & 0 deletions dandi/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@ def ensure_folder():

yield {"message": exists_msg + " - reuploading"}

# For "internal" use -- primarily for use with existing == "overwrite-metadata"
if os.environ.get("DANDI_UPLOAD_SAME_MUST_EXIST"):
if not file_recs:
yield skip_file("File does not exist!")
return
if remote_file_status != "same":
yield skip_file("File is not the same!")
return

#
# 4. Extract metadata - delayed since takes time, but is done
# before actual upload, so we could skip if this fails
Expand Down Expand Up @@ -688,6 +697,10 @@ def skip_file(msg):
raise NotImplementedError(
"No existing=overwrite-metadata for new dandi-api version (yet)"
)
if os.environ.get("DANDI_UPLOAD_SAME_MUST_EXIST"):
raise NotImplementedError(
"Not DANDI_UPLOAD_SAME_MUST_EXIST in new dandi-api version (yet)"
)

# TODO: we might want to always yield a full record so no field is not
# provided to pyout to cause it to halt
Expand Down