ReScience / articles

ReScience C published articles
6 stars 5 forks source link

[BUG] article.code.doi is never None, its empty string #3

Closed koustuvsinha closed 4 years ago

koustuvsinha commented 4 years ago

In publish script, article.code.doi is checked for None, where as its an empty string, even when code doi is removed from metadata.yaml. This leads to the following error:

Updating metadata to Zenodo... [{'field': 'metadata.related_identifiers.0.identifier', 'message': 'Not a valid persistent identifier. Identifier is required.'}]
Traceback (most recent call last):
  File "articles/publish.py", line 219, in <module>
    update_metadata(server, token, article_id, article)
  File "articles/publish.py", line 103, in update_metadata
    raise IOError("%s: " % response.status_code + response.json()["message"])
OSError: 400: Validation error.

Changing it to this logic will solve it:

if article.code.doi is not None and len(article.code.doi) > 0:
koustuvsinha commented 4 years ago

Context Issue : https://github.com/ReScience/NeurIPS-2019/issues/31

ThomasA commented 4 years ago

An even more Pythonic way to achieve the same solution would be:

if article.code.doi:
rougier commented 4 years ago

I just encountered the bug and fixed but the fix by @ThomasA would have been better. Care to make a PR?

ThomasA commented 4 years ago

I can do that. It's in my queue...

rougier commented 4 years ago

Thanks.

ThomasA commented 4 years ago

Thanks for your patience. The simplification is now in #16.

rougier commented 4 years ago

And merged. Thanks.