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

Upgrade resource usage tracker (Pydantic v2) #6517

Conversation

giancarloromeo
Copy link
Contributor

What do these changes do?

Upgrade resource usage tracker to Pydantic v2.

Related issue/s

How to test

Dev-ops checklist

@giancarloromeo giancarloromeo changed the base branch from master to pydantic_v2_migration October 11, 2024 07:59
@giancarloromeo giancarloromeo self-assigned this Oct 11, 2024
@giancarloromeo giancarloromeo added the t:maintenance Some planned maintenance work label Oct 11, 2024
@giancarloromeo giancarloromeo added this to the MartinKippenberger milestone Oct 11, 2024
@giancarloromeo giancarloromeo changed the title WIP: Upgrade resource usage tracker WIP: Upgrade resource usage tracker (Pydantic v2) Oct 11, 2024
Copy link

codecov bot commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
...racker/modules/db/repositories/resource_tracker.py 93.3% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##             pydantic_v2_migration   #6517   +/-   ##
=======================================================
  Coverage                         ?   84.9%           
=======================================================
  Files                            ?     593           
  Lines                            ?   22405           
  Branches                         ?     719           
=======================================================
  Hits                             ?   19037           
  Misses                           ?    3241           
  Partials                         ?     127           
Flag Coverage Δ
unittests 84.9% <98.3%> (?)

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

Files with missing lines Coverage Δ
...emas_resource_usage_tracker/credit_transactions.py 100.0% <100.0%> (ø)
...pi_schemas_resource_usage_tracker/pricing_plans.py 100.0% <100.0%> (ø)
...ages/settings-library/src/settings_library/base.py 89.2% <100.0%> (ø)
...rc/simcore_service_resource_usage_tracker/_meta.py 100.0% <100.0%> (ø)
...esource_usage_tracker/api/rpc/_resource_tracker.py 100.0% <ø> (ø)
...service_resource_usage_tracker/core/application.py 100.0% <100.0%> (ø)
...core_service_resource_usage_tracker/core/errors.py 100.0% <100.0%> (ø)
...re_service_resource_usage_tracker/core/settings.py 100.0% <100.0%> (ø)
...ker/models/resource_tracker_credit_transactions.py 100.0% <100.0%> (ø)
...e_tracker/models/resource_tracker_pricing_plans.py 100.0% <100.0%> (ø)
... and 7 more

@giancarloromeo giancarloromeo added the a:resource-usage-tracker resource usage tracker service label Oct 16, 2024
@giancarloromeo giancarloromeo changed the title WIP: Upgrade resource usage tracker (Pydantic v2) Upgrade resource usage tracker (Pydantic v2) Oct 21, 2024
@giancarloromeo giancarloromeo marked this pull request as ready for review October 21, 2024 09:43
@giancarloromeo giancarloromeo requested a review from GitHK October 21, 2024 09:43
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

just some questions about the Decimal changes.

Comment on lines +17 to +18
BeforeValidator(lambda x: round(x, 2)),
PlainSerializer(float, return_type=float, when_used='json')
Copy link
Member

Choose a reason for hiding this comment

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

3 questions here:

  • why do we need to do that?
  • is the BeforeValidator having the same behavior as the old Decimal ? (in which case I am wondering if the new Decimal is better? or not? @matusdrobuliak66 @pcrespov )
  • PlainSerializer, is that when we output to json it creates a plain float? is this actually valid json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PlainSerializer is used here to serialize as float the Decimal field that from Pydantic v2 would be returned as str in the JSON serialization. Without it the OpenAPI schema would have a field of type string instead of number, changing the interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

If unit tests are passing, then it should be fine (we have some tests for this Decimal checks)

Copy link
Member

Choose a reason for hiding this comment

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

@matusdrobuliak66 I’m quite skeptical about the changes in these Decimal ... should be test it further ?:-(

Copy link

Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

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

Thanks! let me know if help is needed to fix some failing tests

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

👍

@giancarloromeo giancarloromeo merged commit bb61da5 into ITISFoundation:pydantic_v2_migration Oct 21, 2024
45 of 58 checks passed
@giancarloromeo giancarloromeo deleted the is4481/upgrade-resource-usage-tracker branch October 21, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:resource-usage-tracker resource usage tracker service 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
4 participants