Skip to content

Commit

Permalink
add Eduardo's advice
Browse files Browse the repository at this point in the history
Signed-off-by: Future-Outlier <[email protected]>
  • Loading branch information
Future-Outlier committed Oct 25, 2024
1 parent 76ae0ef commit dfe8762
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/pythonbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ jobs:
- flytekit-pandera
- flytekit-papermill
- flytekit-polars
# TODO: remove pydantic v1 plugin, since v2 is in core already
# flytekit-pydantic
- flytekit-ray
- flytekit-snowflake
- flytekit-spark
Expand Down
13 changes: 11 additions & 2 deletions flytekit/core/type_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,17 @@ def to_python_value(self, ctx: FlyteContext, lv: Literal, expected_python_type:

def from_binary_idl(self, binary_idl_object: Binary, expected_python_type: Type[T]) -> Optional[T]:
"""
TODO: Add more comments to explain the lifecycle of attribute access.
This is for dict, dataclass, and dataclass attribute access.
This function primarily handles deserialization for untyped dicts, dataclasses, Pydantic BaseModels, and attribute access.`
For untyped dict, dataclass, and pydantic basemodel:
Life Cycle (Untyped Dict as example):
python val -> msgpack bytes -> binary literal scalar -> msgpack bytes -> python val
(to_literal) (from_binary_idl)
For attribute access:
Life Cycle:
python val -> msgpack bytes -> binary literal scalar -> resolved golang value -> binary literal scalar -> msgpack bytes -> python val
(to_literal) (propeller attribute access) (from_binary_idl)
"""
if binary_idl_object.tag == MESSAGEPACK:
try:
Expand Down
4 changes: 2 additions & 2 deletions flytekit/extras/pydantic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

from . import transformer
except (ImportError, OSError) as e:
logger.info(f"Meet error when importing pydantic: `{e}`")
logger.info("Flytekit only support pydantic version > 2.")
logger.warning(f"Meet error when importing pydantic: `{e}`")
logger.warning("Flytekit only support pydantic version > 2.")
2 changes: 1 addition & 1 deletion flytekit/extras/pydantic/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pydantic import model_serializer, model_validator

except ImportError:
logger.info(
logger.warning(
"Pydantic is not installed.\n" "Please install Pydantic version > 2 to use FlyteTypes in pydantic BaseModel."
)

Expand Down
5 changes: 5 additions & 0 deletions plugins/flytekit-pydantic/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Flytekit Pydantic Plugin
## Warning
This plugin is deprecated and will be removed in the future.

Please directly install `pydantic` and use `BaseModel` in your Flyte tasks.

## Introduction
Pydantic is a data validation and settings management library that uses Python type annotations to enforce type hints at runtime and provide user-friendly errors when data is invalid. Pydantic models are classes that inherit from `pydantic.BaseModel` and are used to define the structure and validation of data using Python type annotations.

The plugin adds type support for pydantic models.
Expand Down

0 comments on commit dfe8762

Please sign in to comment.