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

⬆️ 0.8/pydantic2 fix #1378

Merged
merged 17 commits into from
Oct 21, 2023
Merged

⬆️ 0.8/pydantic2 fix #1378

merged 17 commits into from
Oct 21, 2023

Conversation

s-weigand
Copy link
Member

This is based on #1368 but I made a separate PR so @joernweissenborn can review my changes.

Upgrading to pydantic 2 is the first step we need to take before we can make schema generation work.

@s-weigand s-weigand requested review from jsnel, a team and joernweissenborn as code owners October 20, 2023 19:26
@github-actions
Copy link
Contributor

Binder 👈 Launch a binder notebook on branch s-weigand/pyglotaran/0.8/pydantic2-fix

@s-weigand s-weigand mentioned this pull request Oct 20, 2023
@@ -38,6 +38,34 @@
META_VALIDATOR = "__glotaran_validator__"


class GlotaranFieldMetadata(UserDict):
Copy link
Member Author

Choose a reason for hiding this comment

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

I know this whole thing isn't really pretty but we need to it keeps us going for now until we reevaluate the need for an extra evaluation mechanism.

@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Files Coverage Δ
glotaran/builtin/elements/baseline/element.py 90.0% <100.0%> (ø)
glotaran/builtin/elements/clp_guide/element.py 100.0% <100.0%> (ø)
...aran/builtin/elements/coherent_artifact/element.py 77.2% <100.0%> (+0.2%) ⬆️
...ran/builtin/elements/damped_oscillation/element.py 94.3% <100.0%> (+<0.1%) ⬆️
glotaran/builtin/elements/kinetic/element.py 89.7% <100.0%> (+0.1%) ⬆️
glotaran/builtin/elements/spectral/element.py 85.0% <100.0%> (ø)
glotaran/io/preprocessor/preprocessor.py 100.0% <100.0%> (ø)
glotaran/model/data_model.py 87.7% <100.0%> (+0.1%) ⬆️
glotaran/model/experiment_model.py 100.0% <100.0%> (ø)
glotaran/optimization/optimization.py 78.0% <100.0%> (+0.3%) ⬆️
... and 8 more

📢 Thoughts on this report? Let us know!.

@s-weigand
Copy link
Member Author

We still need to deal with

glotaran/plugin_system/base_registry.py:130
glotaran/plugin_system/base_registry.py:130
glotaran/plugin_system/base_registry.py:130
glotaran/plugin_system/base_registry.py:130
glotaran/plugin_system/base_registry.py:130
glotaran/plugin_system/base_registry.py:130
  /home/runner/work/pyglotaran/pyglotaran/glotaran/plugin_system/base_registry.py:130: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
    for entry_points in [entry_points[p] for p in plugin_names]:  # type:ignore[assignment]

../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:128
  /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:128: UserWarning: Field "model_interval" has conflict with protected namespace "model_".
  
  You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.
    warnings.warn(

../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
  /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163: UserWarning: Field name "register_as" shadows an attribute in parent "Element"; 
    warnings.warn(

../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
  /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163: UserWarning: Field name "data_model_type" shadows an attribute in parent "Element"; 
    warnings.warn(

../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
  /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163: UserWarning: Field name "data_model_type" shadows an attribute in parent "ExtendableElement"; 
    warnings.warn(

../../../../../opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163
  /opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pydantic/_internal/_fields.py:163: UserWarning: Field name "register_as" shadows an attribute in parent "ExtendableElement"; 
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

But those are for a different discussion and PR 😅

Copy link
Member

@jsnel jsnel left a comment

Choose a reason for hiding this comment

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

Changes look sound to me

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@joernweissenborn joernweissenborn left a comment

Choose a reason for hiding this comment

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

Lgtm

@jsnel jsnel merged commit 26f45f4 into glotaran:staging Oct 21, 2023
16 of 32 checks passed
@jsnel jsnel deleted the 0.8/pydantic2-fix branch October 21, 2023 14:57
jsnel added a commit to jsnel/pyglotaran that referenced this pull request Jun 2, 2024
Various fixes related to the pydantic1 to pydantic2 upgrade.

Some details:
* Autoconvert to pydantic 2.
* Replace missing clasing with any.
* Adapted typing for pydantic 2.
* Check if Factory is needed
and update requirements_dev.txt so as to not get into CI trouble
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* 🩹 Fix assignment of literal type to type attribute
* 🩹 Use RootModel instead of BaseModel and __root__
* 🩹 Replace deprecated parse_obj with model_validate
* 🩹 Fix accessing of element data_model_type
* 🩹 Undefined -> PydanticUndefined
* 🩹 Adjust to removal of ModelField
https://docs.pydantic.dev/latest/migration/#changes-to-validators-allowed-signatures
* 🧪🩹 Adapt to schema changes
* 🧪🩹 Fix pydantic validation error in test
* 🧪🩹 Fix definition MockElementWithDataModel.data_model_type
Without the type annotation it is omitted from the fields
* 🧹 Replace .dict with .model_dump
* 🧹 Replace .copy with .model_copy
* 🤖 Refactored by Sourcery

---------

Co-authored-by: Joern Weissenborn <joern.weissenborn@gmail.com>
Co-authored-by: Joris Snellenburg <jsnel@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sourcery AI <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants