Skip to content

Commit c784048

Browse files
committed
ENH: log dandischema version and ensure we log (consistently) path for log messages in download
1 parent fdd65d0 commit c784048

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

dandi/cli/command.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ def main(ctx, log_level, pdb=False):
116116
root.addHandler(handler)
117117

118118
lgr.info(
119-
"dandi v%s, hdmf v%s, pynwb v%s, h5py v%s",
119+
"dandi v%s, dandischema v%s, hdmf v%s, pynwb v%s, h5py v%s",
120120
__version__,
121+
get_module_version("dandischema"),
121122
get_module_version("hdmf"),
122123
get_module_version("pynwb"),
123124
get_module_version("h5py"),

dandi/download.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,9 @@ def _download_file(
685685
if digester is not None:
686686
break
687687
if digester is None:
688-
lgr.warning("Found no digests in hashlib for any of %s", str(digests))
688+
lgr.warning(
689+
"%s - found no digests in hashlib for any of %s", path, str(digests)
690+
)
689691

690692
# TODO: how do we discover the total size????
691693
# TODO: do not do it in-place, but rather into some "hidden" file
@@ -718,7 +720,8 @@ def _download_file(
718720
warned = True
719721
# Yield ERROR?
720722
lgr.warning(
721-
"Downloaded %d bytes although size was told to be just %d",
723+
"%s - downloaded %d bytes although size was told to be just %d",
724+
path,
722725
downloaded,
723726
size,
724727
)
@@ -746,14 +749,15 @@ def _download_file(
746749
*RETRY_STATUSES,
747750
)
748751
):
749-
lgr.debug("Download failed: %s", exc)
752+
lgr.debug("%s - download failed: %s", path, exc)
750753
yield {"status": "error", "message": str(exc)}
751754
return
752755
# if is_access_denied(exc) or attempt >= 2:
753756
# raise
754757
# sleep a little and retry
755758
lgr.debug(
756-
"Failed to download on attempt #%d: %s, will sleep a bit and retry",
759+
"%s - failed to download on attempt #%d: %s, will sleep a bit and retry",
760+
path,
757761
attempt,
758762
exc,
759763
)
@@ -768,11 +772,11 @@ def _download_file(
768772
if digest != final_digest:
769773
msg = f"{algo}: downloaded {final_digest} != {digest}"
770774
yield {"checksum": "differs", "status": "error", "message": msg}
771-
lgr.debug("%s is different: %s.", path, msg)
775+
lgr.debug("%s - is different: %s.", path, msg)
772776
return
773777
else:
774778
yield {"checksum": "ok"}
775-
lgr.debug("Verified that %s has correct %s %s", path, algo, digest)
779+
lgr.debug("%s - verified that has correct %s %s", path, algo, digest)
776780
else:
777781
# shouldn't happen with more recent metadata etc
778782
yield {

0 commit comments

Comments
 (0)