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

⬆️Pydantic V2: Diverse fixes after merges from master #6627

Conversation

sanderegg
Copy link
Member

@sanderegg sanderegg commented Oct 29, 2024

What do these changes do?

  • removed FieldNotRequired this is not supported anymore
  • NOTE that writing
class MyClass:
  my_int: int | None

in pydantic V1 would validate when my_int was "forgotten" and set it as None. This is not anymore the case in V2 which is the expected behavior.

Also in V2, FieldNotRequired, which was abusing that concept is not supported anymore.

@matusdrobuliak66 @pcrespov Please check:

  • services/payments/src/simcore_service_payments/models/db.py changes in example for PaymentsTransactionsDB and 'PaymentsMethodsDB' that were missing values

Related issue/s

How to test

Dev-ops checklist

@sanderegg sanderegg added t:maintenance Some planned maintenance work efs-guardian labels Oct 29, 2024
@sanderegg sanderegg self-assigned this Oct 29, 2024
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

@sanderegg sanderegg added this to the Caveman milestone Oct 29, 2024
@sanderegg sanderegg force-pushed the migration/fix-tests branch from 304d440 to 3baa3f8 Compare October 29, 2024 10:56
@sanderegg sanderegg requested a review from pcrespov as a code owner October 29, 2024 10:56
@sanderegg sanderegg changed the title ⬆️Fix tests after merges ⬆️Pydantic V2: Fix tests after merges Oct 29, 2024
@sanderegg sanderegg changed the title ⬆️Pydantic V2: Fix tests after merges ⬆️Pydantic V2: Diverse fixes after merges from master Oct 29, 2024
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 70.55%. Comparing base (afa0b3c) to head (367c12b).
Report is 1 commits behind head on pydantic_v2_migration_do_not_squash_updates.

Additional details and impacted files
@@                               Coverage Diff                               @@
##           pydantic_v2_migration_do_not_squash_updates    #6627      +/-   ##
===============================================================================
- Coverage                                        70.69%   70.55%   -0.15%     
===============================================================================
  Files                                             1029      922     -107     
  Lines                                            46799    42955    -3844     
  Branches                                          1243      434     -809     
===============================================================================
- Hits                                             33086    30308    -2778     
+ Misses                                           13492    12555     -937     
+ Partials                                           221       92     -129     
Flag Coverage Δ *Carryforward flag
integrationtests 64.78% <ø> (-0.01%) ⬇️ Carriedforward from 2e20fb8
unittests 83.44% <50.00%> (+2.60%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library 83.79% <ø> (ø)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration 70.00% <ø> (ø)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 77.44% <ø> (ø)
agent 97.21% <ø> (ø)
api_server ∅ <ø> (∅)
autoscaling 95.25% <ø> (ø)
catalog ∅ <ø> (∅)
clusters_keeper 98.85% <ø> (ø)
dask_sidecar 90.84% <ø> (ø)
datcore_adapter 93.14% <ø> (ø)
director 58.38% <ø> (ø)
director_v2 76.20% <ø> (ø)
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 59.66% <ø> (ø)
efs_guardian 87.12% <43.75%> (∅)
invitations 93.44% <ø> (ø)
osparc_gateway_server 85.41% <ø> (ø)
payments 92.98% <100.00%> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage 89.63% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 59.66% <ø> (-0.02%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afa0b3c...367c12b. Read the comment docs.

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

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

Please double check my highlights

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@sanderegg sanderegg merged commit 9e76d4f into ITISFoundation:pydantic_v2_migration_do_not_squash_updates Oct 29, 2024
70 of 89 checks passed
@sanderegg sanderegg deleted the migration/fix-tests branch October 29, 2024 20:54
@@ -107,13 +110,15 @@ class ProjectReplace(InputSchema):
last_change_date: DateTimeStr
workbench: NodesDict
access_rights: dict[GroupIDStr, AccessRights]
tags: list[int] | None = []
tags: list[int] | None = Field(
default_factory=list, json_schema_extra={"default": []}
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the rest noticed this. perhaps add it in the description of the PR ?

quality: dict[str, Any] = FieldNotRequired()

_empty_is_none = field_validator("thumbnail", allow_reuse=True, pre=True)(
name: ShortTruncatedStr | None = Field(default=None)
Copy link
Member

Choose a reason for hiding this comment

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

Why you add Field when we only look for the default?

THOUGHT: I wonder if we should start using Annotated instead of abusing of the "exception to the rule" of adding a default (i.e. Field) that is not an instance of the type annotated. It kind of similar to the story with FieldRequired that exploited an edge case that now was removed.

class MyModel(BaseModel):
      foo: Annotated[LongTruncatedStr | None , Field(description="foo is the opposite of bar")] = None

Perhaps is an unnecessary burden ... it does not really pay off!

@@ -27,6 +28,8 @@
"invoice_pdf_url": None,
"initiated_at": "2023-09-27T10:00:00",
"state": PaymentTransactionState.PENDING,
"completed_at": None,
Copy link
Member

Choose a reason for hiding this comment

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

this is fine

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

Successfully merging this pull request may close these issues.

5 participants