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

Update links resources #306

Merged
merged 5 commits into from
Jun 11, 2020
Merged

Update links resources #306

merged 5 commits into from
Jun 11, 2020

Conversation

CasperWA
Copy link
Member

Fixes #299

This PR implements the upcoming changes to the LinksResource, updating the OpenAPIs from the pydantic models as well as the related tests.

ChildResource, ParentResource, and ProviderResource has all been removed. They were not used in any case, and the new link_type has gotten the Literal type to "validate" the value.

Note: This PR will fail until providers.optimade.org updates their links resources to the new schema, and changes may still occur, since the update has not yet been merged into the OPTIMADE API specification.

@CasperWA
Copy link
Member Author

CasperWA commented Jun 11, 2020

This has now been implemented in the specification through Materials-Consortia/OPTIMADE#273. This PR should align itself with the spec PR and as soon as the providers repository has been updated accordingly, this PR is ready.

Edit: Currently waiting for the providers PR Materials-Consortia/providers#34

@giovannipizzi
Copy link

Ah, maybe this is why the resources started returning plain dicts instead of python objects with attributes in the tests I am adding in Materials-Consortia/providers#34?

When this is merged, will dictionary key access continue working or I should change back the test code?

@CasperWA
Copy link
Member Author

CasperWA commented Jun 11, 2020

Ah, maybe this is why the resources started returning plain dicts instead of python objects with attributes in the tests I am adding in Materials-Consortia/providers#34?

Right, yeah! So we have ourselves a circular dependency issue here.

When this is merged, will dictionary key access continue working or I should change back the test code?

I've just tested this. No, unfortunately not.

Maybe I should not have closed Materials-Consortia/providers#37 after all?

@giovannipizzi
Copy link

I see. I guess that anyway the ultimate solution is to pin the version of the python tools in the tests. Feel free to reopen Materials-Consortia/providers#37 and we merge that first (note my comment on one missing link_type in there)

Fix type to "links".
Add `link_type` property with the Literals: "child", "root", "external",
"provider"
Tests will fail until provider.optimade.org is updated with the new
links resource definition.
@CasperWA CasperWA force-pushed the fix_299-update-links-resources branch from 0c8d838 to a84987d Compare June 11, 2020 20:21
@codecov
Copy link

codecov bot commented Jun 11, 2020

Codecov Report

Merging #306 into master will decrease coverage by 0.00%.
The diff coverage is 68.42%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
- Coverage   90.12%   90.11%   -0.01%     
==========================================
  Files          55       55              
  Lines        2289     2287       -2     
==========================================
- Hits         2063     2061       -2     
  Misses        226      226              
Flag Coverage Δ
#unittests 90.11% <68.42%> (-0.01%) ⬇️
Impacted Files Coverage Δ
optimade/server/routers/index_info.py 100.00% <ø> (ø)
optimade/validator/validator.py 74.29% <0.00%> (+0.26%) ⬆️
optimade/models/links.py 90.90% <83.33%> (-1.69%) ⬇️
optimade/models/index_metadb.py 94.44% <88.88%> (-5.56%) ⬇️

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 c0e0b35...bf0e161. Read the comment docs.

@CasperWA CasperWA changed the title [WIP] Update links resources Update links resources Jun 11, 2020
@CasperWA
Copy link
Member Author

Can anyone tell me why the OpenAPI CI check fails for these changes?

@shyamd
Copy link
Contributor

shyamd commented Jun 11, 2020

Equally perplexed by the OpenAPI JSON. I don't like how much of a circular dependency we have. In the future we should:
1.) Use dependabot to track changes in that repo
2.) Have pulling the "version" of the providers specification as part of the build/test workflow rather than just grabbing the latest version.

@CasperWA
Copy link
Member Author

Can anyone tell me why the OpenAPI CI check fails for these changes?

Doing some local testing it seems the checker fails if using Literal in the pydantic types - for whatever reason. I don't know if this means the openapi.json schema is wrong when generating it using Literal, or if the validator is wrong ...

@CasperWA
Copy link
Member Author

Equally perplexed by the OpenAPI JSON. I don't like how much of a circular dependency we have. In the future we should:
1.) Use dependabot to track changes in that repo
2.) Have pulling the "version" of the providers specification as part of the build/test workflow rather than just grabbing the latest version.

What do you mean exactly with "version" in 2)? We have been testing pulling the list of providers always, albeit implicitly.

@CasperWA
Copy link
Member Author

@ml-evs @shyamd please review, this is all ready to go :)

shyamd
shyamd previously approved these changes Jun 11, 2020
optimade/models/links.py Outdated Show resolved Hide resolved
optimade/models/index_metadb.py Outdated Show resolved Hide resolved
Co-Authored-By: Matthew Evans <me388@cam.ac.uk>
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.

🥇

@ml-evs ml-evs merged commit 10ea60a into master Jun 11, 2020
@CasperWA CasperWA deleted the fix_299-update-links-resources branch June 11, 2020 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update links resources
4 participants