Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Conditional imports to support pydantic>2 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguidry authored Oct 4, 2023
1 parent e3cd8ab commit 4eaadeb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion prefect_kubernetes/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
from prefect import task
from prefect.blocks.abstract import JobBlock, JobRun
from prefect.utilities.asyncutils import run_sync_in_worker_thread, sync_compatible
from pydantic import Field
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field
else:
from pydantic import Field

from typing_extensions import Self

from prefect_kubernetes.credentials import KubernetesCredentials
Expand Down
8 changes: 7 additions & 1 deletion prefect_kubernetes/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@
BaseWorker,
BaseWorkerResult,
)
from pydantic import Field, validator
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import Field, validator
else:
from pydantic import Field, validator

from typing_extensions import Literal

from prefect_kubernetes.events import KubernetesEventsReplicator
Expand Down
7 changes: 6 additions & 1 deletion tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
temporary_settings,
)
from prefect.utilities.dockerutils import get_prefect_image_name
from pydantic import ValidationError
from pydantic import VERSION as PYDANTIC_VERSION

if PYDANTIC_VERSION.startswith("2."):
from pydantic.v1 import ValidationError
else:
from pydantic import ValidationError

from prefect_kubernetes import KubernetesWorker
from prefect_kubernetes.utilities import _slugify_label_value
Expand Down

0 comments on commit 4eaadeb

Please sign in to comment.