Skip to content

Commit

Permalink
ENH: log dandischema version and ensure we log (consistently) path fo…
Browse files Browse the repository at this point in the history
…r log messages in download
  • Loading branch information
yarikoptic committed Sep 27, 2024
1 parent fdd65d0 commit c784048
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion dandi/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ def main(ctx, log_level, pdb=False):
root.addHandler(handler)

lgr.info(
"dandi v%s, hdmf v%s, pynwb v%s, h5py v%s",
"dandi v%s, dandischema v%s, hdmf v%s, pynwb v%s, h5py v%s",
__version__,
get_module_version("dandischema"),
get_module_version("hdmf"),
get_module_version("pynwb"),
get_module_version("h5py"),
Expand Down
16 changes: 10 additions & 6 deletions dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ def _download_file(
if digester is not None:
break
if digester is None:
lgr.warning("Found no digests in hashlib for any of %s", str(digests))
lgr.warning(

Check warning on line 688 in dandi/download.py

View check run for this annotation

Codecov / codecov/patch

dandi/download.py#L688

Added line #L688 was not covered by tests
"%s - found no digests in hashlib for any of %s", path, str(digests)
)

# TODO: how do we discover the total size????
# TODO: do not do it in-place, but rather into some "hidden" file
Expand Down Expand Up @@ -718,7 +720,8 @@ def _download_file(
warned = True
# Yield ERROR?
lgr.warning(
"Downloaded %d bytes although size was told to be just %d",
"%s - downloaded %d bytes although size was told to be just %d",
path,
downloaded,
size,
)
Expand Down Expand Up @@ -746,14 +749,15 @@ def _download_file(
*RETRY_STATUSES,
)
):
lgr.debug("Download failed: %s", exc)
lgr.debug("%s - download failed: %s", path, exc)

Check warning on line 752 in dandi/download.py

View check run for this annotation

Codecov / codecov/patch

dandi/download.py#L752

Added line #L752 was not covered by tests
yield {"status": "error", "message": str(exc)}
return
# if is_access_denied(exc) or attempt >= 2:
# raise
# sleep a little and retry
lgr.debug(
"Failed to download on attempt #%d: %s, will sleep a bit and retry",
"%s - failed to download on attempt #%d: %s, will sleep a bit and retry",
path,
attempt,
exc,
)
Expand All @@ -768,11 +772,11 @@ def _download_file(
if digest != final_digest:
msg = f"{algo}: downloaded {final_digest} != {digest}"
yield {"checksum": "differs", "status": "error", "message": msg}
lgr.debug("%s is different: %s.", path, msg)
lgr.debug("%s - is different: %s.", path, msg)

Check warning on line 775 in dandi/download.py

View check run for this annotation

Codecov / codecov/patch

dandi/download.py#L775

Added line #L775 was not covered by tests
return
else:
yield {"checksum": "ok"}
lgr.debug("Verified that %s has correct %s %s", path, algo, digest)
lgr.debug("%s - verified that has correct %s %s", path, algo, digest)
else:
# shouldn't happen with more recent metadata etc
yield {
Expand Down

0 comments on commit c784048

Please sign in to comment.