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

⬆️ WIP: Upgrade libraries (pydantic v2) #6366

Draft
wants to merge 116 commits into
base: pydantic_v2_migration
Choose a base branch
from

Conversation

giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Sep 16, 2024

What do these changes do?

Upgrade libraries (inside packages folder) to Pydantic v2.

Note: the models-library has a dedicated PR (see #6333)

Related issue/s

How to test

Dev-ops checklist

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

Attention: Patch coverage is 92.59259% with 30 lines in your changes missing coverage. Please review.

Please upload report for BASE (pydantic_v2_migration@d2d81c0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...ackages/aws-library/src/aws_library/ec2/_models.py 52.6% 9 Missing ⚠️
...ages/settings-library/src/settings_library/base.py 86.9% 4 Missing and 2 partials ⚠️
...s/models-library/src/models_library/basic_regex.py 25.0% 3 Missing ⚠️
.../settings-library/src/settings_library/postgres.py 66.6% 2 Missing and 1 partial ⚠️
...settings-library/src/settings_library/utils_cli.py 92.8% 1 Missing and 1 partial ⚠️
...ls-library/src/models_library/rabbitmq_messages.py 0.0% 1 Missing ⚠️
...integration/src/service_integration/cli/_config.py 66.6% 0 Missing and 1 partial ⚠️
...egration/src/service_integration/oci_image_spec.py 85.7% 1 Missing ⚠️
...ettings-library/src/settings_library/prometheus.py 0.0% 1 Missing ⚠️
...es/settings-library/src/settings_library/rabbit.py 66.6% 1 Missing ⚠️
... and 2 more
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##             pydantic_v2_migration   #6366   +/-   ##
=======================================================
  Coverage                         ?   82.4%           
=======================================================
  Files                            ?     389           
  Lines                            ?   13032           
  Branches                         ?    1144           
=======================================================
  Hits                             ?   10739           
  Misses                           ?    2145           
  Partials                         ?     148           
Flag Coverage Δ
unittests 82.4% <92.5%> (?)

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

Files with missing lines Coverage Δ
...ackages/aws-library/src/aws_library/ec2/_client.py 100.0% <ø> (ø)
packages/aws-library/src/aws_library/s3/_client.py 95.3% <100.0%> (ø)
...kages/aws-library/src/aws_library/s3/_constants.py 100.0% <100.0%> (ø)
packages/aws-library/src/aws_library/s3/_errors.py 100.0% <100.0%> (ø)
packages/aws-library/src/aws_library/s3/_utils.py 100.0% <100.0%> (ø)
...ackages/aws-library/src/aws_library/ssm/_client.py 97.7% <100.0%> (ø)
...ackages/aws-library/src/aws_library/ssm/_errors.py 100.0% <100.0%> (ø)
...dask_task_models_library/container_tasks/docker.py 100.0% <100.0%> (ø)
...dask_task_models_library/container_tasks/errors.py 100.0% <100.0%> (ø)
...dask_task_models_library/container_tasks/events.py 91.8% <100.0%> (ø)
... and 64 more

@giancarloromeo giancarloromeo changed the title ⬆️ WIP: Upgrade libraries ⬆️ WIP: Upgrade libraries (pydantic v2) Sep 16, 2024
@giancarloromeo giancarloromeo self-assigned this Sep 16, 2024
@giancarloromeo giancarloromeo added the t:maintenance Some planned maintenance work label Sep 16, 2024
@giancarloromeo giancarloromeo added this to the Doppelbock milestone Sep 16, 2024
@giancarloromeo giancarloromeo linked an issue Sep 18, 2024 that may be closed by this pull request
# dsn is computed from the other fields
assert "dsn" not in settings.dict()

# causes cached property to be computed and stored on the instance
Copy link
Contributor Author

@giancarloromeo giancarloromeo Sep 25, 2024

Choose a reason for hiding this comment

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

In Pydantic v2, it is possible to annotate @computed_field. It must be specified in advance if we want to include it in the model serialization. By default @computed_field(repr=True) for public fields, @computed_field(repr=False) for private ones.

See: https://docs.pydantic.dev/2.0/usage/computed_fields/

)

# test cached-property
assert settings.log_level == logging.DEBUG
# log_level is cached-property (notice that is lower-case!), and gets added after first use
Copy link
Contributor Author

@giancarloromeo giancarloromeo Sep 25, 2024

Choose a reason for hiding this comment

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

In Pydantic v2, it is possible to annotate @computed_field. It must be specified in advance if we want to include it in the model serialization. By default @computed_field(repr=True) for public fields, @computed_field(repr=False) for private ones.

See: https://docs.pydantic.dev/2.0/usage/computed_fields/

Copy link

sonarcloud bot commented Sep 27, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Major upgrade to pydantic 2.0
1 participant