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

chore: remove warnings from pydantic v2 #183

Merged
merged 8 commits into from
Oct 30, 2023
Merged

chore: remove warnings from pydantic v2 #183

merged 8 commits into from
Oct 30, 2023

Conversation

ThibaultFy
Copy link
Member

@ThibaultFy ThibaultFy commented Oct 19, 2023

Related issue

closes FL-1241

  • If the feature has an impact on the user experience, the changelog has been updated
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • The commit message follows the conventional commit specification

@linear
Copy link

linear bot commented Oct 19, 2023

FL-1241 Deprecated `dict` method in Pydantic

Context

Running documentation example MNIST Cyclic raised the following warning:

PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0.

Specification

Remove usages of dict method in MNIST Cyclic and everywhere else it is still used

Acceptance criteria

Running MNIST Cyclic does not raise the deprecation warning anymore

@ThibaultFy ThibaultFy changed the title chore: replace dict by model_dump chore: remove warnings from pydantic v2 Oct 20, 2023
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
@ThibaultFy ThibaultFy marked this pull request as ready for review October 20, 2023 15:23
@ThibaultFy ThibaultFy requested a review from a team as a code owner October 20, 2023 15:23
Copy link
Contributor

@SdgJlbl SdgJlbl left a comment

Choose a reason for hiding this comment

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

Thank you :)

Copy link
Contributor

@guilhem-barthes guilhem-barthes left a comment

Choose a reason for hiding this comment

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

Thanks!

@ThibaultFy
Copy link
Member Author

/e2e -h

@Owlfred
Copy link

Owlfred commented Oct 23, 2023

Usage: /e2e [options] [help]

/e2e may appear anywhere as long as it is on its own line

Options:
  --refs <value>                          Extra refs (branch or tag) with format REPO=GIT_REF,REPO=GIT_REF.
  Supported repositories: orchestrator, substra-backend, substra-frontend, substra-tools, substrafl, substra, substra-tests, substra-documentation, substra-ci.
  Example: /e2e --refs substra-backend=some_branch,orchestrator=some_tag (default: {})
  --tests-to-run, --tests <tests-to-run>  Comma-separated list of tests to run. Valid options: sdk, substrafl, doc, frontend, mnist, camelyon or NONE. (default: "sdk")
  -h, --help                              display help for command

@thbcmlowk
Copy link
Contributor

thbcmlowk commented Oct 23, 2023

I saw more pydantic warnings to be fixed in the CI logs. For instance:

substrafl/dependency/schemas.py:86
  /usr/src/app/substrafl/substrafl/dependency/schemas.py:86: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    @validator("local_installable_dependencies", "local_code")
  /usr/local/lib/python3.11/site-packages/pydantic/_internal/_config.py:267: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

It might be [quote] << worth >> [unquote] fixing them in this PR. WDYT?

@ThibaultFy
Copy link
Member Author

I saw more pydantic warnings to be fixed in the CI logs. For instance:

substrafl/dependency/schemas.py:86
  /usr/src/app/substrafl/substrafl/dependency/schemas.py:86: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    @validator("local_installable_dependencies", "local_code")
  /usr/local/lib/python3.11/site-packages/pydantic/_internal/_config.py:267: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

It might be [quote] << worth >> [unquote] fixing them in this PR. WDYT?

Yep I tried to fix them too. It's linked to the fact we are overwritting the __del__ function in Dependencies, and pydentic overwrite __delattr__on there side. These two + the pytest management on garbage collection seems to be 💥 . These logs does not appears to users with a "normal" usage of dependencies... I can continue to look at this though..

@thbcmlowk
Copy link
Contributor

I saw more pydantic warnings to be fixed in the CI logs. For instance:

substrafl/dependency/schemas.py:86
  /usr/src/app/substrafl/substrafl/dependency/schemas.py:86: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    @validator("local_installable_dependencies", "local_code")
  /usr/local/lib/python3.11/site-packages/pydantic/_internal/_config.py:267: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.4/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

It might be [quote] << worth >> [unquote] fixing them in this PR. WDYT?

Yep I tried to fix them too. It's linked to the fact we are overwritting the __del__ function in Dependencies, and pydentic overwrite __delattr__on there side. These two + the pytest management on garbage collection seems to be 💥 . These logs does not appears to users with a "normal" usage of dependencies... I can continue to look at this though..

No worries, not that big of deal. It was just in case it was an easy fix. Thanks for looking at it in the first place!

@ThibaultFy ThibaultFy merged commit 325a43f into main Oct 30, 2023
7 checks passed
@ThibaultFy ThibaultFy deleted the remove-dict branch October 30, 2023 10:28
ThibaultFy added a commit that referenced this pull request Jan 30, 2024
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.

5 participants