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
numpy.ndarray
The actual value to be transformed
python_type
typing.Type[numpy.ndarray]
The assumed type of the value (this matches the declared type on the function)
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)
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)