BF: Retain git-annex error messages & don't show them if operation successful#6070
Conversation
mih
left a comment
There was a problem hiding this comment.
Thx! I like the direction.
Looking at the test failures, I think they are legit. Some tests expect the error messages to be rendered/provided specifically as they were. Those need to be adjusted.
The PR also includes a number of unrelated formatting changes. I personally very much appreciate this type of cleanup. However, I would prefer to separate no-op formatting changes from topical changes in separate commits. Future forensics will be more straightforward. Not need to disentangle them for this one, just mentioning it.
On it. I should probably run the tests myself before I submit a PR in the future, huh.
Yeah, I had PyCharm do it's magic a couple of times out of habit, sorry. |
| if not k.endswith('lastchanged')} | ||
| if d.get('error-messages', None): | ||
| messages.extend(d['error-messages']) | ||
| res['error_message'] = '\n'.join(m.strip() for m in d['error-messages']) |
There was a problem hiding this comment.
I wonder whether such a join should only happen in result renderer(s). When using the python interface it may be beneficial to have a structured record in error_message.
There was a problem hiding this comment.
I merely reproduced what was already being done a couple of lines below:
if messages: res['message'] = '\n'.join(m.strip() for m in messages)
There was a problem hiding this comment.
Q is what are the semantics here? Do we know that this is one message with several lines, or several messages. So far the the message key had one purpose: carry a message to be displayed. If it shall become a message-building toolkit instead, we should work this out properly in #6054, and not introduce things in a single location, just for annex messages.
Codecov Report
@@ Coverage Diff @@
## maint #6070 +/- ##
==========================================
- Coverage 90.25% 88.43% -1.83%
==========================================
Files 312 312
Lines 42214 42217 +3
==========================================
- Hits 38099 37333 -766
- Misses 4115 4884 +769
Continue to review full report at Codecov.
|
|
Regarding AppVeyor error:
I use |
That's strange indeed. I vaguely remember running into this bc of some meant-to-be-convenient- but-actually-confusing auto conversion python3 does when reading/writing files. Like reading |
|
Windows? |
5246dfc to
d223782
Compare
d223782 to
477d86e
Compare
mih
left a comment
There was a problem hiding this comment.
OK, so with this PR I see:
{
"action": "get",
"annexkey": "MD5E-s32338--3cb12b68abd59160dffdf4830e1de8bb.nii.gz",
"error_message": "download failed: Not Found\nfailed to download content\ndownload failed: Not Found\nfailed to download content\ndownload failed: Not Found\nfailed to download content",
"path": "/tmp/studyforrest-data/derivative/aggregate_fmri_timeseries/sub-10/atlases/bold3Tp2/shen_fconn_atlas_150.nii.gz",
"refds": "/tmp/studyforrest-data",
"status": "ok",
"type": "file"
}
rendered as
get(ok): derivative/aggregate_fmri_timeseries/sub-10/atlases/bold3Tp2/shen_fconn_atlas_150.nii.gz (file)
[download failed: Not Found
failed to download content
download failed: Not Found
failed to download content
download failed: Not Found
failed to download content]
which doesn't match the "& don't show them if operation successful" part of the PR title. Is that intentional?
If so, maybe a message prefix ala "intermediate errors occurred: " or something along these lines.
Also I would personally prefer no preemptive linebreaks in the reporting (i.e. before the [)
| if not k.endswith('lastchanged')} | ||
| if d.get('error-messages', None): | ||
| messages.extend(d['error-messages']) | ||
| res['error_message'] = '\n'.join(m.strip() for m in d['error-messages']) |
There was a problem hiding this comment.
Q is what are the semantics here? Do we know that this is one message with several lines, or several messages. So far the the message key had one purpose: carry a message to be displayed. If it shall become a message-building toolkit instead, we should work this out properly in #6054, and not introduce things in a single location, just for annex messages.
Absolutely not. I had multiple versions of this code before submitting the PR, and somewhere in the middle the "test" I used (from #5617) stopped working for me. I must have forgotten to re-add the status check at some point after that & didn't notice. |
Why? From what I can tell, it is pretty obvious that any message is supposed to be a multi-line block. Personally, I find it incredibly ugly to see a multi-line block not start on a new line. |
The original error-messages contains, in general, multiple messages each with at least one line. We can distinguish lines, but not messages. So the general form of |
mih
left a comment
There was a problem hiding this comment.
OK, this now works as advertised, thx much!
Also I would personally prefer no preemptive linebreaks in the reporting (i.e. before the [)
Why? From what I can tell, it is pretty obvious that any message is supposed to be a multi-line block. Personally, I find it incredibly ugly to see a multi-line block not start on a new line.
Actually, no. Overall, most messages are quite concise single line statements. Now they are forced on a separate line. The [ ... ] format was originally chosen to have some kind of a line/result-continuation indicator.
If the format of the default result rendering is to be changed, I think there should be a dedicated issue about this, and a separate fix -- not piggy-backing on an unrelated change.
70f3d53 to
6962030
Compare
6962030 to
fcc2a2d
Compare
mih
left a comment
There was a problem hiding this comment.
Great, thx for the update. Please feel free, and encouraged to propose a format change for the default renderer output!
Description
Instead of being mashed into a 'normal' message, git-annex reported error messages will now be retained in a separate dict entry.
This allows for more differentiated handling of them. Examples implemented in this PR:
Related Issues
datalad getcan still look quite sad #5617