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

Add references endpoint #78

Merged
merged 12 commits into from Nov 21, 2019
Merged

Add references endpoint #78

merged 12 commits into from Nov 21, 2019

Conversation

CasperWA
Copy link
Member

@CasperWA CasperWA commented Nov 12, 2019

Closes #69
Closes #70

Short description

This PR adds the /references endpoint (as well as /info/references and /references/{entry_id}) to the server.

Additional changes

Changes made in order to ease the incorporation of references, and in the future, more entry endpoints:

  • The old StructureResponseMany and StructureResponseOne have been renamed to EntryResponseMany and EntryResponseOne. The resource model used is the EntryResource, so new entry resource models must subclass this resource.
    • NOTE: For the validator, it is imperative to keep the specific Validator*Response, where * is any entry resource, since the validator has to check whether an endpoint then also produces the correct resources. Therefore ValidatorReferenceResponseMany and ValidatorReferenceResponseOne have been added.
  • Update EntryCollection and MongoCollection to be mapper agnostic, i.e., pass a specific mapper class, when initializing a collection.
    • This makes these collection classes completely resource agnostic.
  • Create a base ResourceMapper that contains the generally used class methods. StructureMapper now subclasses this class.
  • Create the ReferenceMapper. As of now, it is basically a complete copy of StructureMapper, barring some structure-specific lines in StructureMapper.
  • Add test_references.json with a single reference. For now, this reference matches the example from the spec (see here).

Other "minor" changes:

  • Put all provider information into config.ini and load it into CONFIG.provider as a dictionary.
  • Update the existing provider information with the Example provider from providers.json in the OPTiMaDe repository (here)
  • Move all utility functions from main.py into utils.py and clean up main.py.
    • NOTE: The entry endpoints now use the same utility function to create their responses, only differentiated by passing the correct collection to the utility function.
  • The optimade_validator tool has had its verbosity set to a default of 1 (it was 0).

Also update provider information in meta to align with providers.json on
Materials-Consortia/OPTiMaDe on github.com
Moved all utility functions used by the server in main.py into utils.py.

Abstracted some things away to utility functions and BaseClassres, in
order to easier create new entry endpoints.

Added /references, /references/{entry_id}, and /info/references to the
validator.
@CasperWA CasperWA added this to In progress in Road to optimade-python-tools 1.0 via automation Nov 12, 2019
@CasperWA CasperWA force-pushed the close_69_add_references_endpoint branch from 1276fea to e948504 Compare November 12, 2019 18:43
@codecov
Copy link

codecov bot commented Nov 12, 2019

Codecov Report

Merging #78 into master will increase coverage by 0.71%.
The diff coverage is 82.99%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
+ Coverage   84.36%   85.08%   +0.71%     
==========================================
  Files          35       38       +3     
  Lines        2111     2212     +101     
==========================================
+ Hits         1781     1882     +101     
  Misses        330      330
Impacted Files Coverage Δ
optimade/validator/__init__.py 13.04% <0%> (ø) ⬆️
optimade/server/config.py 79.54% <100%> (+2.8%) ⬆️
optimade/server/mappers/entries.py 100% <100%> (ø)
optimade/server/entry_collections.py 83.73% <100%> (+0.13%) ⬆️
optimade/validator/validator_model_patches.py 100% <100%> (ø) ⬆️
optimade/server/mappers/structures.py 93.33% <100%> (-0.96%) ⬇️
optimade/server/mappers/__init__.py 100% <100%> (ø) ⬆️
optimade/server/tests/test_server.py 88.42% <100%> (+0.49%) ⬆️
optimade/models/references.py 100% <100%> (+4.87%) ⬆️
optimade/models/toplevel.py 100% <100%> (ø) ⬆️
... and 8 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 0b26bc3...5fef46b. Read the comment docs.

@CasperWA CasperWA force-pushed the close_69_add_references_endpoint branch from e948504 to 6ac75e1 Compare November 12, 2019 18:44
In order for openapi.json to include the StructureResource and
ReferenceResource, the specific resource response models are needed.
@ltalirz ltalirz mentioned this pull request Nov 14, 2019
16 tasks
ml-evs
ml-evs previously approved these changes Nov 15, 2019
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Thanks for this @CasperWA, merge when you're happy.

LGTM after testing locally (and adding a few extra endpoint tests), can't see anything worth changing in the code :)

Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

Thanks @CasperWA, still LGTM, I'm going to quickly add the relationship from the test structures to this reference and add tests for that machinery.

optimade/server/main.py Show resolved Hide resolved
@CasperWA
Copy link
Member Author

(...) I'm going to quickly add the relationship from the test structures to this reference and add tests for that machinery.

If it's okay with you, I'd rather just merge this and then do relationships in another PR, unless you think it will be short and painful?

@ml-evs
Copy link
Member

ml-evs commented Nov 21, 2019

(...) I'm going to quickly add the relationship from the test structures to this reference and add tests for that machinery.

If it's okay with you, I'd rather just merge this and then do relationships in another PR, unless you think it will be short and painful?

Yeah that's fair enough, I have something nearly working but its worth scrutiny as a new PR.

@ml-evs ml-evs self-requested a review November 21, 2019 12:37
@ml-evs ml-evs merged commit c3a8995 into master Nov 21, 2019
Road to optimade-python-tools 1.0 automation moved this from In progress to Done Nov 21, 2019
@CasperWA CasperWA deleted the close_69_add_references_endpoint branch November 21, 2019 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Possibly make /info/{endpoint} dynamic Add missing /references endpoint to server
2 participants