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

BF: annexjson2result() did not report 'error-messages' (fixes gh-3870) #3931

Merged
merged 1 commit into from Dec 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions datalad/interface/results.py
Expand Up @@ -212,6 +212,7 @@ def annexjson2result(d, ds, **kwargs):
Passes as-is to `get_status_dict`. Must not contain `refds`.
"""
lgr.debug('received JSON result from annex: %s', d)
messages = []
res = get_status_dict(**kwargs)
res['status'] = 'ok' if d.get('success', False) is True else 'error'
# we cannot rely on any of these to be available as the feed from
Expand All @@ -227,13 +228,18 @@ def annexjson2result(d, ds, **kwargs):
res['metadata'] = {k: v[0] if isinstance(v, list) and len(v) == 1 else v
for k, v in d['fields'].items()
if not k.endswith('lastchanged')}
# avoid meaningless standard messages
if 'note' in d:
if d.get('error-messages', None):
messages.extend(d['error-messages'])
# avoid meaningless standard messages, and collision with actual error
# messages
elif 'note' in d:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that errors are more important, but I wonder if note should also be retained?
i.e. elif to be changed back to if?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the example I posted. I think it makes it worse.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there is no way to keep error message "separate" so it could e.g. get a distinctive color (red) while rendering the result?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have that yet, but I recorded the need #3939

note = "; ".join(ln for ln in d['note'].splitlines()
if ln != 'checksum...'
and not ln.startswith('checking file'))
if note:
res['message'] = translate_annex_notes.get(note, note)
messages.append(translate_annex_notes.get(note, note))
if messages:
res['message'] = '\n'.join(m.strip() for m in messages)
return res


Expand Down