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(ingest): start working on pydantic v2 support #9220

Merged
merged 4 commits into from
Nov 10, 2023

Conversation

hsheth2
Copy link
Collaborator

@hsheth2 hsheth2 commented Nov 10, 2023

Note that this does not fully enabled pydantic v2 compatibility yet (#8829). However, it lays the groundwork for doing so in the future.

Given the large surface area of changes, I want to merge this quickly so that we can avoid merge conflicts.

  • Ran a dry-run version of the bump-pydantic codemod.
  • Adds skip_on_failures to non-pre root validators. This will reduce the quality of our error messages a bit.
  • Makes None the explicit default for fields that are optional
  • Adds type annotations for inherited config fields, as well as for a few fields that were missing them.

Remaining TODOs

  • Make sure we covered all the Optional[x] fields when adding the default of None.
  • Migrate the data contracts subcommand - it uses root models, which don't really translate cleanly between pydantic 1 and 2.
  • Figure out how to replicate parse_obj_allow_extras (and more broadly, get all the tests to pass with pydantic 2)

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

Note that this does not fully enabled pydantic v2 compatibility yet.
However, it lays the groundwork for doing so in the future.
@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Nov 10, 2023
@hsheth2 hsheth2 changed the title chore(ingest): start migrating to pydantic v2 chore(ingest): start working on pydantic v2 support Nov 10, 2023
yield cls.validate
yield pydantic.validators.enum_member_validator
if PYDANTIC_VERSION_2:
# if TYPE_CHECKING:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentionally commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes - mainly as a marker for how to type this function in the future

@hsheth2 hsheth2 merged commit 89dff8f into datahub-project:master Nov 10, 2023
51 checks passed
@hsheth2 hsheth2 deleted the pydantic-2-start branch November 10, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ingestion PR or Issue related to the ingestion of metadata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants