-
Notifications
You must be signed in to change notification settings - Fork 27
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
♻️ catalog API schema models moved to models-library #4553
♻️ catalog API schema models moved to models-library #4553
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4553 +/- ##
========================================
+ Coverage 86.6% 88.2% +1.6%
========================================
Files 746 898 +152
Lines 34139 39706 +5567
Branches 647 876 +229
========================================
+ Hits 29570 35059 +5489
- Misses 4415 4445 +30
- Partials 154 202 +48
Flags with carried forward coverage won't be shown. Click here to find out more.
|
94756b2
to
f8ee2fd
Compare
4a7feaa
to
cfa1c85
Compare
Code Climate has analyzed commit cfa1c85 and detected 0 issues on this pull request. View more on Code Climate. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, only one doubt about how the validators are registered.
I don't see an advantage, I would say only a disadvantage.
_from_equivalent_enums = validator("type", allow_reuse=True, pre=True)( | ||
create_enums_pre_validator(ClusterTypeInModel) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get it, this is a validator. Why is it register like this and not as a decorated function?
I find it less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This technique is used to reuse validators. The validators I add in models_library.utils.common_validators
are solutions to common pitfalls. The Enum problem is one of them and therefore it is very convenient to have a tested solution in place instead of being reinventing a solution in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got that.
My question was more in the likes of why not do something like this:
@validator(allow_reuse=True, pre=True)
@classmethod
def _from_equivalent_enums(cli, values):
return create_enums_pre_validator(values)
Since this is the format to whom we are normally used to?
What do these changes do?
Basically, it moves the pydantic models for the
catalog
services (i.e.models/schemas
) tomodels_library.api_schemas_catalog
. This way both server and client can share these models. This PR only affects tocatalog
andmodels_library
. Changes in the clients (e.g.web-server
orapi-server
will be done in separate PRs).models-library
Config.schema_extra
exposed examples inmodels_library
. SEEpackages/models-library/tests/test__models_examples.py
!import simcore_postgres_database.models.cluster.ClusterType
inmodels_library
. This PR introduces a duplicated enum and adapts pydantic model to handle it until next PR.test__pydantic_models_and_enums.py
catalog
's schemas tomodels-library.api_schemas_catalog
:webserver
,api-server
dag
API entrypoint -> upgradesservices/catalog version: 0.4.0 → 0.5.0
Next PR will do the same but with the schema models of director-v2, i.e. they will be moved to
models_library
.Related issue/s
How to test
Driving tests were:
packages/models-library/tests/test__pydantic_models_and_enums.py
packages/models-library/tests/test_utils_common_validators.py
catalog
services andmodels_library
DevOps
None