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

Fix: Make the library more robust for publishing #41

Merged
merged 9 commits into from
Jun 18, 2021
Merged

Conversation

satra
Copy link
Member

@satra satra commented Jun 18, 2021

  1. updates datacite constructor to ensure
  • contributorType
  • support validation against jsonschema from datacite (this may not be authoritative and should be used with care)
  1. ensure that round tripping of schemaKey creates the same object or raises a validation error

closes dandi/dandi-archive#347

@satra satra added patch Increment the patch version when merged release Create a release when this pr is merged labels Jun 18, 2021
@codecov
Copy link

codecov bot commented Jun 18, 2021

Codecov Report

Merging #41 (d7b9a92) into master (054544f) will increase coverage by 1.20%.
The diff coverage is 97.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   94.51%   95.72%   +1.20%     
==========================================
  Files          11       11              
  Lines         857     1005     +148     
==========================================
+ Hits          810      962     +152     
+ Misses         47       43       -4     
Flag Coverage Δ
unittests 95.72% <97.39%> (+1.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dandischema/metadata.py 96.55% <95.23%> (+0.47%) ⬆️
dandischema/models.py 93.71% <96.42%> (+1.86%) ⬆️
dandischema/consts.py 100.00% <100.00%> (ø)
dandischema/datacite.py 94.79% <100.00%> (+0.96%) ⬆️
dandischema/tests/test_datacite.py 100.00% <100.00%> (ø)
dandischema/tests/test_metadata.py 100.00% <100.00%> (ø)
dandischema/tests/test_models.py 95.12% <100.00%> (+0.47%) ⬆️
dandischema/tests/test_utils.py 100.00% <100.00%> (ø)
dandischema/utils.py 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update caddcd3...d7b9a92. Read the comment docs.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

some minor comments from cursory review

return datacite_dict


def _get_datacite_schema():
Copy link
Member

Choose a reason for hiding this comment

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

I know that it is just a code move.

But this better be cached or (even without any analysis of how often this is called) we might end up with all kinds fails upon some intermittent connection issues etc.
Or might be better to just include that file right here in the dandischema sources/distribution -- who knows what RFing they would decide to do in datacite etc. Then this file would always be with us and reliably available -- would make it more robust.

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's why i have left that by default as False. we should have some trust no?

people can retry on http errors for anyone using the code. i will at least make it a permalink.

if "Published" in cls.__name__:
tempval = "Published" + tempval
if "BareAsset" == cls.__name__:
tempval = "Bare" + tempval
Copy link
Member

Choose a reason for hiding this comment

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

so it could make it BarePublished<val>? shouldn't Published be added later so it would be PublishedBare<val>?

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 should not happen here. the second if is an equality check, in which case the only value tempval should have is Asset, thus turning it into BareAsset. anything else it should throw an error in the next few lines.

@satra
Copy link
Member Author

satra commented Jun 18, 2021

@yarikoptic - feel free to merge this tomorrow if you have no other changes to make.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

If we talk about "more robust": I still think we should cache online fetching, and if someone is to retry -- it is for a fetcher . But that could be done later, so I am ok to proceed

@satra satra merged commit 3facfd4 into master Jun 18, 2021
@satra satra deleted the fix/datacite branch June 18, 2021 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTPError: 422 Client Error: Unprocessable Entity for url: https://api.test.datacite.org/dois
2 participants