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

Commit

Permalink
Fix pydantic import to handle v2
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiobasile committed Oct 16, 2023
1 parent 8042510 commit b2bee15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fix pydantic imports to handle v2 support from Prefect - [#26](https://github.com/giorgiobasile/prefect-planetary-computer/pull/26)

### Security

## 0.1.0
Expand Down
11 changes: 8 additions & 3 deletions prefect_planetary_computer/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
from dask_gateway.auth import JupyterHubAuth
from prefect.blocks.core import Block
from prefect_dask import DaskTaskRunner
from pydantic import Field, SecretStr
from pydantic import VERSION as PYDANTIC_VERSION

from prefect_planetary_computer.constants import (
CATALOG_URL,
GATEWAY_ADDRESS,
GATEWAY_PROXY_ADDRESS,
)

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


class PlanetaryComputerCredentials(Block):
"""
Expand All @@ -27,8 +32,8 @@ class PlanetaryComputerCredentials(Block):
to instantiate clusters through Dask Gateway.
Args:
subscription_key (str): A subscription key to access the full PC data catalog.
hub_api_token (str): The JupyterHub API token to instantiate clusters through Dask Gateway.
subscription_key (str, optional): A subscription key to access the full PC data catalog.
hub_api_token (str, optional): The JupyterHub API token to instantiate clusters through Dask Gateway.
Example:
Load stored Planetary Computer credentials:
Expand Down

0 comments on commit b2bee15

Please sign in to comment.