-
Notifications
You must be signed in to change notification settings - Fork 25
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
BF: guard download_generator to not propagate errors #1008
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1008 +/- ##
==========================================
+ Coverage 88.53% 88.56% +0.03%
==========================================
Files 73 74 +1
Lines 9295 9307 +12
==========================================
+ Hits 8229 8243 +14
+ Misses 1066 1064 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
apparently there is a test which ensured that individual calls would raise exception
so may be this PR "wouldn't work as is" since it would change semantic of |
debdf1f
to
8db314c
Compare
…rts for type checking
This way instead of dumping all tracebacks at the end, some times for benign FileExistsError -- they will be displayed neatly in pyout and also output in detail in the log by default in the case of pyout output handling. But in "debug" mode we will not do anything like that. Closes #1007
8db314c
to
4001ad5
Compare
This pull request introduces 1 alert when merging 4001ad5 into 84f3ead - view on LGTM.com new alerts:
|
I believe this PR also addresses #1030. |
dandi/download.py
Outdated
def _download_generator_guard(path: str, generator: Iterator[dict]) -> Iterator[dict]: | ||
try: | ||
for resp in generator: | ||
yield dict(resp, path=path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already adding path
to the dict on lines 323 and 326. There's no reason to do it again here, and there's a possibility that doing so would mess with pyout.
yield { | ||
"path": path, | ||
"status": "error", | ||
"message": str(exc.__class__.__name__), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you don't want to include the error message via str(exc)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's do str
"message": str(exc.__class__.__name__), | |
"message": str(exc), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back on this since then it becomes "too verbose" with each message just repeating the known path and summary duplicating all those
$> dandi download DANDI:000029
PATH SIZE DONE DONE% CHECKSUM STATUS MESSAGE
dandiset.yaml skipped no change
...64/sub-anm369964_behavior+ecephys.nwb error File './000029/sub...
...63/sub-anm369963_behavior+ecephys.nwb error File './000029/sub...
...62/sub-anm369962_behavior+ecephys.nwb error File './000029/sub...
sub-RAT123/sub-RAT123.nwb error File './000029/sub...
sample.txt error File './000029/sam...
sample.json error File './000029/sam...
Summary: 0 Bytes 0 Bytes 1 skipped 1 no change
+20.7 MB 0.00% 6 error 1 File './000029/s...
1 File './000029/s...
1 File './000029/s...
1 File './000029/s...
1 File './000029/s...
1 File './000029/s...
2022-08-03 11:38:10,873 [ INFO] Logs saved in /home/yoh/.cache/dandi-cli/log/20220803153807Z-1022747.log
(dev3) 1 41191.....................................:Wed 03 Aug 2022 11:38:12 AM EDT:.
lena:/tmp
$> dandi download DANDI:000029
PATH SIZE DONE DONE% CHECKSUM STATUS MESSAGE
dandiset.yaml skipped no change
sub-anm369964/sub-anm369964_behavior+ecephys.nwb error File './000029/sub-anm369964/sub-anm369964_behavior+ecephys.nwb' already exists
sub-anm369963/sub-anm369963_behavior+ecephys.nwb error File './000029/sub-anm369963/sub-anm369963_behavior+ecephys.nwb' already exists
sub-anm369962/sub-anm369962_behavior+ecephys.nwb error File './000029/sub-anm369962/sub-anm369962_behavior+ecephys.nwb' already exists
sub-RAT123/sub-RAT123.nwb error File './000029/sub-RAT123/sub-RAT123.nwb' already exists
sample.txt error File './000029/sample.txt' already exists
sample.json error File './000029/sample.json' already exists
Summary: 0 Bytes 0 Bytes 1 skipped 1 no change
+20.7 MB 0.00% 6 error 1 File './000029/sub-anm369964/sub-anm369964_behavior+ecephys.nwb' already exists
1 File './000029/sub-anm369963/sub-anm369963_behavior+ecephys.nwb' already exists
1 File './000029/sub-anm369962/sub-anm369962_behavior+ecephys.nwb' already exists
1 File './000029/sub-RAT123/sub-RAT123.nwb' already exists
1 File './000029/sample.txt' already exists
1 File './000029/sample.json' already exists
with only reporting the class we have better depiction with details of exception present in the log:
$> dandi download DANDI:000029
PATH SIZE DONE DONE% CHECKSUM STATUS MESSAGE
dandiset.yaml skipped no change
sub-anm369964/sub-anm369964_behavior+ecephys.nwb error FileExistsError
sub-anm369963/sub-anm369963_behavior+ecephys.nwb error FileExistsError
sub-anm369962/sub-anm369962_behavior+ecephys.nwb error FileExistsError
sub-RAT123/sub-RAT123.nwb error FileExistsError
sample.txt error FileExistsError
sample.json error FileExistsError
Summary: 0 Bytes 0 Bytes 1 skipped 1 no change
+20.7 MB 0.00% 6 error 6 FileExistsError
2022-08-03 11:41:08,828 [ INFO] Logs saved in /home/yoh/.cache/dandi-cli/log/20220803154105Z-1024172.log
Co-authored-by: John T. Wodder II <jwodder@users.noreply.github.com>
ec6761b
to
f72c2a8
Compare
This pull request introduces 1 alert when merging f72c2a8 into 84f3ead - view on LGTM.com new alerts:
|
This way instead of dumping all tracebacks at the end, some times for benign
FileExistsError -- they will be displayed neatly in pyout and also output
in detail in the log.
Closes #1007
Closes #1030 (thanks @jwodder for pointing that out below)
on_error
option fordownload_generator
so we could still regularly raise in"-f debug"