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 to pydantic v1 #110

Merged
merged 11 commits into from Jan 7, 2020

Conversation

CasperWA
Copy link
Member

@CasperWA CasperWA commented Dec 8, 2019

Fixes #101
Fixes #111

So far, this PR fixes the server so that it runs, pass all tests (locally) as well as the optimade-validator.

The whole of the server and all models should still be run through to check what else should be upgraded. E.g., introduce root validators, utilize new constrained types and more.

@CasperWA
Copy link
Member Author

CasperWA commented Dec 8, 2019

This may supersede the old PR #56 or reimplement the commits/ideas from there, providing full or co-authorship to @ltalirz (when these concepts have been implemented in this PR).

@ml-evs
Copy link
Member

ml-evs commented Dec 10, 2019

Happy with this so far, thanks @CasperWA. Anything I can do to help? Is it worth trying to do #104 here too, or in a separate PR?

@CasperWA
Copy link
Member Author

Happy with this so far, thanks @CasperWA. Anything I can do to help? Is it worth trying to do #104 here too, or in a separate PR?

This should be in a separate PR in my opinion.
However, you are very welcome to help in moving to v1.2 here 👍

@CasperWA CasperWA mentioned this pull request Dec 10, 2019
3 tasks
@CasperWA
Copy link
Member Author

Latest commit fixes #111, re-instating the commented-out validator.

ml-evs
ml-evs previously approved these changes Dec 22, 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.

Cant see any issues with this, thanks @CasperWA!

@CasperWA
Copy link
Member Author

CasperWA commented Dec 22, 2019

Cant see any issues with this, thanks @CasperWA!

Cheers. I still want to go through all validators, see what can be updated according to the new v1 of pydantic, i.e., using root-validators, etc.
I think I will do this when bored in the holidays here. So I'll go through this page to see what we should check and perhaps update.
But we can also do this in another PR? I don't know. Getting this in as is, will see all of our tests starting to pass again...

@CasperWA
Copy link
Member Author

I am having a hard time understanding why the tests related to relationships are currently failing. It seems the loading of the test structures into the mongomock db is failling to store the relationships field. At least that's the conclusion I have arrived at when printing doc in the map_back function.

@CasperWA
Copy link
Member Author

I am having a hard time understanding why the tests related to relationships are currently failing. It seems the loading of the test structures into the mongomock db is failling to store the relationships field. At least that's the conclusion I have arrived at when printing doc in the map_back function.

I have pin-pointed it to the root_validator of the Attributes model under optimade.models.jsonapi. If this is returned to its previous state, all tests run fine (locally). But I have a hard time understanding why this is the case.

@CasperWA
Copy link
Member Author

CasperWA commented Dec 22, 2019

I am having a hard time understanding why the tests related to relationships are currently failing. It seems the loading of the test structures into the mongomock db is failling to store the relationships field. At least that's the conclusion I have arrived at when printing doc in the map_back function.

I have pin-pointed it to the root_validator of the Attributes model under optimade.models.jsonapi. If this is returned to its previous state, all tests run fine (locally). But I have a hard time understanding why this is the case.

Figured it out. It was a matter of hard-coding top-level non-attributes fields in _parse_params in the collection class: It should not be hard-coded ;)

@CasperWA
Copy link
Member Author

@ml-evs I think this is ready for review + merge. I suggest any further pydantic "upgrades" can be put into separate PRs.

@CasperWA CasperWA requested a review from ml-evs December 22, 2019 23:30
@ml-evs
Copy link
Member

ml-evs commented Dec 23, 2019

Any idea why pre-commit is failing for the openapi generation? I can't match the diff we get from the CI... (seems to be happening to a few PRs)

@CasperWA
Copy link
Member Author

Any idea why pre-commit is failing for the openapi generation? I can't match the diff we get from the CI... (seems to be happening to a few PRs)

No idea. It is weird. But as long as the openapi test is not failing this should be fine. We can always choose to remove the check from the pre-commit, however, I do like it for commits.

@ltalirz ltalirz mentioned this pull request Dec 24, 2019
16 tasks
@ltalirz
Copy link
Member

ltalirz commented Jan 6, 2020

@CasperWA Can you fix the conflicts so that we can get this merged?

@CasperWA
Copy link
Member Author

CasperWA commented Jan 7, 2020

@CasperWA Can you fix the conflicts so that we can get this merged?

Hereby done. The pre-commit is still failing, specifically the json-diff check, but this is irrelevant, since the openapi test succeeds, and this is essentially what we are testing.
I am not sure why this is failing on GH Actions (it is not failing locally). But in any case, the important one of these two checks (json-diff under pre-commit vs. openapi) is the openapi check.

@CasperWA CasperWA changed the title Update to pydantic v1.2 Update to pydantic v1 Jan 7, 2020
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.

I get the same behavior (i.e. it works locally) so happy to merge this and chalk it up to one of life's mysteries...

Thanks again @CasperWA!

@ltalirz
Copy link
Member

ltalirz commented Jan 7, 2020

Thanks for checking @ml-evs !
Good to go then!

@ml-evs ml-evs merged commit a252260 into Materials-Consortia:master Jan 7, 2020
@CasperWA CasperWA deleted the fix_101_pydantic_v1 branch January 8, 2020 09:39
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.

Commented-out validator FastAPI v0.44.0 supports pydantic > 1.0.0
3 participants