flytekit.extend.TypeEngine#
- class flytekit.extend.TypeEngine[source]#
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
Methods
- async classmethod async_to_literal(ctx, python_val, python_type, expected)[source]#
Converts a python value of a given type and expected
LiteralType
into a resolvedLiteral
value.- Parameters:
ctx (FlyteContext)
python_val (Any)
python_type (Type[T])
expected (LiteralType)
- Return type:
- async classmethod async_to_python_value(ctx, lv, expected_python_type)[source]#
- Parameters:
ctx (FlyteContext)
lv (Literal)
expected_python_type (Type)
- Return type:
- classmethod get_available_transformers()[source]#
Returns all python types for which transformers are available
- classmethod get_transformer(python_type)[source]#
Implements a recursive search for the transformer.
- Parameters:
python_type (Type)
- Return type:
- classmethod guess_python_type(flyte_type)[source]#
Transforms a flyte-specific
LiteralType
to a regular python value.- Parameters:
flyte_type (LiteralType)
- Return type:
Type[T]
- classmethod guess_python_types(flyte_variable_dict)[source]#
Transforms a dictionary of flyte-specific
Variable
objects to a dictionary of regular python values.
- classmethod named_tuple_to_variable_map(t)[source]#
Converts a python-native
NamedTuple
to a flyte-specific VariableMap of named literals.- Parameters:
t (NamedTuple)
- Return type:
VariableMap
- classmethod register(transformer, additional_types=None)[source]#
This should be used for all types that respond with the right type annotation when you use type(…) function
- Parameters:
transformer (TypeTransformer)
- classmethod register_additional_type(transformer, additional_type, override=False)[source]#
- Parameters:
transformer (TypeTransformer[T])
additional_type (Type[T])
- classmethod to_html(ctx, python_val, expected_python_type)[source]#
- Parameters:
ctx (FlyteContext)
python_val (Any)
- Return type:
- classmethod to_literal(ctx, python_val, python_type, expected)[source]#
The current dance is because we are allowing users to call from an async function, this synchronous to_literal function, and allowing this to_literal function, to then invoke yet another async function, namely an async transformer.
- Parameters:
ctx (FlyteContext)
python_val (Any)
python_type (Type[T])
expected (LiteralType)
- Return type:
- classmethod to_literal_checks(python_val, python_type, expected)[source]#
- Parameters:
python_val (Any)
python_type (Type[T])
expected (LiteralType)
- classmethod to_literal_type(python_type)[source]#
Converts a python type into a flyte specific
LiteralType
- Parameters:
python_type (Type[T])
- Return type:
- classmethod to_python_value(ctx, lv, expected_python_type)[source]#
Converts a Literal value with an expected python type into a python value.
- Parameters:
ctx (FlyteContext)
lv (Literal)
expected_python_type (Type)
- Return type:
- async classmethod unwrap_offloaded_literal(ctx, lv)[source]#
- Parameters:
ctx (FlyteContext)
lv (Literal)
- Return type:
Attributes
- lazy_import_lock = <unlocked _thread.lock object>