The page you navigated to does not exist, so we brought you to the closest page to it.
TypeEngine
TypeEngine Package: flyte.types
Core Extensible TypeEngine of Flytekit. This should be used to extend the capabilities of FlyteKits type system.
Users can implement their own TypeTransformers and register them with the TypeEngine. This will allow special
handling
of user objects
def dict_to_literal_map (
d: typing. Dict[str, typing. Any],
type_hints: Optional[typing. Dict[str, type]],
) -> LiteralMap
Given a dictionary mapping string keys to python values and a dictionary containing guessed types for such
string keys,
convert to a LiteralMap.
Parameter
Type
Description
d
typing.Dict[str, typing.Any]
type_hints
Optional[typing.Dict[str, type]]
def get_available_transformers ()
Returns all python types for which transformers are available
def get_transformer (
python_type: Type,
) -> TypeTransformer
Implements a recursive search for the transformer.
Parameter
Type
Description
python_type
Type
def guess_python_type (
flyte_type: LiteralType,
) -> Type[T]
Transforms a flyte-specific LiteralType to a regular python value.
Parameter
Type
Description
flyte_type
LiteralType
def guess_python_types (
flyte_variable_dict: typing. Dict[str, interface_pb2. Variable],
) -> typing. Dict[str, Type[Any]]
Transforms a dictionary of flyte-specific Variable objects to a dictionary of regular python values.
Parameter
Type
Description
flyte_variable_dict
typing.Dict[str, interface_pb2.Variable]
def lazy_import_transformers ()
Only load the transformers if needed.
def literal_map_to_kwargs (
lm: LiteralMap,
python_types: typing. Optional[typing. Dict[str, type]],
literal_types: typing. Optional[typing. Dict[str, interface_pb2. Variable]],
) -> typing. Dict[str, typing. Any]
Given a LiteralMap (usually an input into a task - intermediate), convert to kwargs for the task
Parameter
Type
Description
lm
LiteralMap
python_types
typing.Optional[typing.Dict[str, type]]
literal_types
typing.Optional[typing.Dict[str, interface_pb2.Variable]]
def named_tuple_to_variable_map (
t: typing. NamedTuple,
) -> interface_pb2. VariableMap
Converts a python-native NamedTuple to a flyte-specific VariableMap of named literals.
Parameter
Type
Description
t
typing.NamedTuple
def register (
transformer: TypeTransformer,
additional_types: Optional[typing. List[Type]],
)
This should be used for all types that respond with the right type annotation when you use type(…) function
Parameter
Type
Description
transformer
TypeTransformer
additional_types
Optional[typing.List[Type]]
def register_additional_type (
transformer: TypeTransformer[T],
additional_type: Type[T],
override,
)
Parameter
Type
Description
transformer
TypeTransformer[T]
additional_type
Type[T]
override
def register_restricted_type (
name: str,
type: Type[T],
)
Parameter
Type
Description
name
str
type
Type[T]
def to_html (
python_val: typing. Any,
expected_python_type: Type[typing. Any],
) -> str
Parameter
Type
Description
python_val
typing.Any
expected_python_type
Type[typing.Any]
def to_literal (
python_val: typing. Any,
python_type: Type[T],
expected: types_pb2. LiteralType,
) -> literals_pb2. Literal
Parameter
Type
Description
python_val
typing.Any
python_type
Type[T]
expected
types_pb2.LiteralType
def to_literal_checks (
python_val: typing. Any,
python_type: Type[T],
expected: LiteralType,
)
Parameter
Type
Description
python_val
typing.Any
python_type
Type[T]
expected
LiteralType
def to_literal_type (
python_type: Type[T],
) -> LiteralType
Converts a python type into a flyte specific LiteralType
Parameter
Type
Description
python_type
Type[T]
def to_python_value (
lv: Literal,
expected_python_type: Type,
) -> typing. Any
Converts a Literal value with an expected python type into a python value.
Parameter
Type
Description
lv
Literal
expected_python_type
Type
def unwrap_offloaded_literal (
lv: literals_pb2. Literal,
) -> literals_pb2. Literal
Parameter
Type
Description
lv
literals_pb2.Literal