flytekit.types.pickle.pickle
| Property |
Type |
Description |
T |
TypeVar |
|
This type is only used by flytekit internally. User should not use this type.
Any type that flyte can’t recognize will become FlytePickle
def from_pickle(
uri: str,
) -> typing.Any
| Parameter |
Type |
Description |
uri |
str |
|
def to_pickle(
ctx: flytekit.core.context_manager.FlyteContext,
python_val: typing.Any,
) -> str
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
|
python_val |
typing.Any |
|
def FlytePickleTransformer()
| Property |
Type |
Description |
is_async |
None |
|
name |
None |
|
python_type |
None |
This returns the python type |
type_assertions_enabled |
None |
Indicates if the transformer wants type assertions to be enabled at the core type engine layer |
def assert_type(
t: typing.Type[~T],
v: ~T,
)
| Parameter |
Type |
Description |
t |
typing.Type[~T] |
|
v |
~T |
|
def async_to_literal(
ctx: flytekit.core.context_manager.FlyteContext,
python_val: ~T,
python_type: typing.Type[~T],
expected: flytekit.models.types.LiteralType,
) -> flytekit.models.literals.Literal
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type.
Implementers should refrain from using type(python_val) instead rely on the passed in python_type. If these
do not match (or are not allowed) the Transformer implementer should raise an AssertionError, clearly stating
what was the mismatch
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
A FlyteContext, useful in accessing the filesystem and other attributes |
python_val |
~T |
The actual value to be transformed |
python_type |
typing.Type[~T] |
The assumed type of the value (this matches the declared type on the function) |
expected |
flytekit.models.types.LiteralType |
Expected Literal Type |
def async_to_python_value(
ctx: flytekit.core.context_manager.FlyteContext,
lv: flytekit.models.literals.Literal,
expected_python_type: typing.Type[~T],
) -> ~T
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
| Parameter |
Type |
Description |
ctx |
flytekit.core.context_manager.FlyteContext |
FlyteContext |
lv |
flytekit.models.literals.Literal |
The received literal Value |
expected_python_type |
typing.Type[~T] |
Expected native python type that should be returned |
def from_binary_idl(
binary_idl_object: Binary,
expected_python_type: Type[T],
) -> Optional[T]
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)
| Parameter |
Type |
Description |
binary_idl_object |
Binary |
|
expected_python_type |
Type[T] |
|
def from_generic_idl(
generic: Struct,
expected_python_type: Type[T],
) -> Optional[T]
TODO: Support all Flyte Types.
This is for dataclass attribute access from input created from the Flyte Console.
Note:
- This can be removed in the future when the Flyte Console support generate Binary IDL Scalar as input.
| Parameter |
Type |
Description |
generic |
Struct |
|
expected_python_type |
Type[T] |
|
def get_literal_type(
t: typing.Type[~T],
) -> flytekit.models.types.LiteralType
Converts the python type to a Flyte LiteralType
| Parameter |
Type |
Description |
t |
typing.Type[~T] |
|
def guess_python_type(
literal_type: flytekit.models.types.LiteralType,
) -> typing.Type[flytekit.types.pickle.pickle.FlytePickle.__class_getitem__.<locals>._SpecificFormatClass]
Converts the Flyte LiteralType to a python object type.
| Parameter |
Type |
Description |
literal_type |
flytekit.models.types.LiteralType |
|
def isinstance_generic(
obj,
generic_alias,
)
| Parameter |
Type |
Description |
obj |
|
|
generic_alias |
|
|
def schema_match(
schema: dict,
) -> bool
Check if a JSON schema fragment matches this transformer’s python_type.
For BaseModel subclasses, automatically compares the schema’s title, type, and
required fields against the type’s own JSON schema. For other types, returns
False by default — override if needed.
| Parameter |
Type |
Description |
schema |
dict |
|
def to_html(
ctx: FlyteContext,
python_val: T,
expected_python_type: Type[T],
) -> str
Converts any python val (dataframe, int, float) to a html string, and it will be wrapped in the HTML div
| Parameter |
Type |
Description |
ctx |
FlyteContext |
|
python_val |
T |
|
expected_python_type |
Type[T] |
|
def to_literal(
ctx: FlyteContext,
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
) -> Literal
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type.
Implementers should refrain from using type(python_val) instead rely on the passed in python_type. If these
do not match (or are not allowed) the Transformer implementer should raise an AssertionError, clearly stating
what was the mismatch
| Parameter |
Type |
Description |
ctx |
FlyteContext |
A FlyteContext, useful in accessing the filesystem and other attributes |
python_val |
typing.Any |
The actual value to be transformed |
python_type |
Type[T] |
The assumed type of the value (this matches the declared type on the function) |
expected |
LiteralType |
Expected Literal Type |
def to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type[T],
) -> Optional[T]
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
| Parameter |
Type |
Description |
ctx |
FlyteContext |
FlyteContext |
lv |
Literal |
The received literal Value |
expected_python_type |
Type[T] |
Expected native python type that should be returned |