Skip to content

Conversation

@giancarloromeo
Copy link
Contributor

What do these changes do?

Upgrade the invitation service (Pydantic v2).

Related issue/s

How to test

Dev-ops checklist

@giancarloromeo giancarloromeo self-assigned this Oct 10, 2024
@giancarloromeo giancarloromeo added this to the MartinKippenberger milestone Oct 10, 2024
@giancarloromeo giancarloromeo added the t:maintenance Some planned maintenance work label Oct 10, 2024
"alias": "c",
},
}
alias_generator=_to_initial,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using the alias_generator removes the need of the code above.

Copy link
Member

@pcrespov pcrespov Oct 11, 2024

Choose a reason for hiding this comment

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

The implementation you did of _to_initial has the risk of producing inadvertently duplicate aliases as we extend the number of fields. An explicit mapping, as we have now, makes a mistake more obvious but I would also add an assert in the code.

I propose to either do an explicit map as an implementation or your first-letter implementation of _to_initial generator but in both cases make sure that there are no repetitions as

assert not [item for item, count in Counter([field.alias for field in _ContentWithShortNames.__fields__.values()]).items() if count > 1]  #nosec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the assert statement as test to catch alias repetition early and have a clean separation between validation and model logic.

@giancarloromeo giancarloromeo changed the title WIP: Upgrade invitations service WIP: Upgrade invitations service (Pydantic v2) Oct 10, 2024
@codecov
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
...common-library/src/common_library/serialization.py 50.0% 1 Missing and 1 partial ⚠️
...s/models-library/src/models_library/invitations.py 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                   @@
##             pydantic_v2_migration   #6513   +/-   ##
=======================================================
  Coverage                         ?   78.5%           
=======================================================
  Files                            ?     304           
  Lines                            ?   11834           
  Branches                         ?     880           
=======================================================
  Hits                             ?    9301           
  Misses                           ?    2410           
  Partials                         ?     123           
Flag Coverage Δ
unittests 78.5% <86.9%> (?)

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

Files with missing lines Coverage Δ
...rc/simcore_service_invitations/api/_invitations.py 100.0% <100.0%> (ø)
...tions/src/simcore_service_invitations/api/_meta.py 100.0% <100.0%> (ø)
...invitations/src/simcore_service_invitations/cli.py 92.1% <100.0%> (ø)
...s/src/simcore_service_invitations/core/settings.py 97.2% <100.0%> (ø)
...imcore_service_invitations/services/invitations.py 97.1% <100.0%> (ø)
...s/models-library/src/models_library/invitations.py 73.0% <0.0%> (ø)
...common-library/src/common_library/serialization.py 58.3% <50.0%> (ø)

@giancarloromeo giancarloromeo changed the title WIP: Upgrade invitations service (Pydantic v2) WIP: ⬆️ Upgrade invitations service (Pydantic v2) Oct 10, 2024
@giancarloromeo giancarloromeo changed the title WIP: ⬆️ Upgrade invitations service (Pydantic v2) Upgrade invitations service (Pydantic v2) Oct 10, 2024
@giancarloromeo giancarloromeo marked this pull request as ready for review October 10, 2024 20:21
@giancarloromeo giancarloromeo requested a review from GitHK October 10, 2024 20:21
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.

🎉

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.

thx. Please check the alias generator

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.

thx

@sonarqubecloud
Copy link

@giancarloromeo giancarloromeo merged commit bbe92a2 into ITISFoundation:pydantic_v2_migration Oct 11, 2024
38 of 56 checks passed
@giancarloromeo giancarloromeo deleted the is4481/upgrade-invitations branch October 11, 2024 09:44
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.

2 participants