flytekit.types.schema.types
Directory
Classes
Class | Description |
---|---|
AsyncTypeTransformer |
Base transformer type that should be implemented for every python native type that can be handled by flytekit. |
Binary |
None. |
DataClassJSONMixin |
None. |
Enum |
Create a collection of name/value pairs. |
FlyteContext |
This is an internal-facing context object, that most users will not have to deal with. |
FlyteContextManager |
FlyteContextManager manages the execution context within Flytekit. |
FlyteSchema |
None. |
FlyteSchemaTransformer |
Base transformer type that should be implemented for every python native type that can be handled by flytekit. |
Literal |
None. |
LiteralType |
None. |
LocalIOSchemaReader |
Base SchemaReader to handle any readers (that can manage their own IO or otherwise). |
LocalIOSchemaWriter |
Abstract base class for generic types. |
Path |
PurePath subclass that can make system calls. |
Scalar |
None. |
Schema |
None. |
SchemaEngine |
This is the core Engine that handles all schema sub-systems. |
SchemaFormat |
Represents the schema storage format (at rest). |
SchemaHandler |
None. |
SchemaOpenMode |
Create a collection of name/value pairs. |
SchemaReader |
Base SchemaReader to handle any readers (that can manage their own IO or otherwise). |
SchemaType |
None. |
SchemaWriter |
Abstract base class for generic types. |
SerializableType |
None. |
Struct |
A ProtocolMessage. |
TypeEngine |
Core Extensible TypeEngine of Flytekit. |
Errors
flytekit.types.schema.types.AsyncTypeTransformer
Base transformer type that should be implemented for every python native type that can be handled by flytekit
def AsyncTypeTransformer(
name: str,
t: Type[T],
enable_type_assertions: bool,
):
Parameter | Type |
---|---|
name |
str |
t |
Type[T] |
enable_type_assertions |
bool |
Methods
Method | Description |
---|---|
assert_type() |
None |
async_to_literal() |
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type |
async_to_python_value() |
Converts the given Literal to a Python Type |
from_binary_idl() |
This function primarily handles deserialization for untyped dicts, dataclasses, Pydantic BaseModels, and attribute access |
from_generic_idl() |
TODO: Support all Flyte Types |
get_literal_type() |
Converts the python type to a Flyte LiteralType |
guess_python_type() |
Converts the Flyte LiteralType to a python object type |
isinstance_generic() |
None |
to_html() |
Converts any python val (dataframe, int, float) to a html string, and it will be wrapped in the HTML div |
to_literal() |
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type |
to_python_value() |
Converts the given Literal to a Python Type |
assert_type()
def assert_type(
t: Type[T],
v: T,
):
Parameter | Type |
---|---|
t |
Type[T] |
v |
T |
async_to_literal()
def async_to_literal(
ctx: FlyteContext,
python_val: T,
python_type: Type[T],
expected: LiteralType,
):
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 |
---|---|
ctx |
FlyteContext |
python_val |
T |
python_type |
Type[T] |
expected |
LiteralType |
async_to_python_value()
def async_to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type[T],
):
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type[T] |
from_binary_idl()
def from_binary_idl(
binary_idl_object: Binary,
expected_python_type: Type[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 |
---|---|
binary_idl_object |
Binary |
expected_python_type |
Type[T] |
from_generic_idl()
def from_generic_idl(
generic: Struct,
expected_python_type: Type[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 |
---|---|
generic |
Struct |
expected_python_type |
Type[T] |
get_literal_type()
def get_literal_type(
t: Type[T],
):
Converts the python type to a Flyte LiteralType
Parameter | Type |
---|---|
t |
Type[T] |
guess_python_type()
def guess_python_type(
literal_type: LiteralType,
):
Converts the Flyte LiteralType to a python object type.
Parameter | Type |
---|---|
literal_type |
LiteralType |
isinstance_generic()
def isinstance_generic(
obj,
generic_alias,
):
Parameter | Type |
---|---|
obj |
|
generic_alias |
to_html()
def to_html(
ctx: FlyteContext,
python_val: T,
expected_python_type: Type[T],
):
Converts any python val (dataframe, int, float) to a html string, and it will be wrapped in the HTML div
Parameter | Type |
---|---|
ctx |
FlyteContext |
python_val |
T |
expected_python_type |
Type[T] |
to_literal()
def to_literal(
ctx: FlyteContext,
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
):
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 |
---|---|
ctx |
FlyteContext |
python_val |
typing.Any |
python_type |
Type[T] |
expected |
LiteralType |
to_python_value()
def to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type[T],
):
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type[T] |
Properties
Property | Type | Description |
---|---|---|
is_async | ||
name | ||
python_type | ||
type_assertions_enabled |
flytekit.types.schema.types.Binary
def Binary(
value,
tag,
):
Parameter | Type |
---|---|
value |
|
tag |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
pb2_object,
):
Parameter | Type |
---|---|
pb2_object |
serialize_to_string()
def serialize_to_string()
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
is_empty | ||
tag | ||
value |
flytekit.types.schema.types.DataClassJSONMixin
Methods
Method | Description |
---|---|
from_dict() |
None |
from_json() |
None |
to_dict() |
None |
to_json() |
None |
from_dict()
def from_dict(
d,
dialect,
):
Parameter | Type |
---|---|
d |
|
dialect |
from_json()
def from_json(
data: typing.Union[str, bytes, bytearray],
decoder: collections.abc.Callable[[typing.Union[str, bytes, bytearray]], dict[typing.Any, typing.Any]],
from_dict_kwargs: typing.Any,
):
Parameter | Type |
---|---|
data |
typing.Union[str, bytes, bytearray] |
decoder |
collections.abc.Callable[[typing.Union[str, bytes, bytearray]], dict[typing.Any, typing.Any]] |
from_dict_kwargs |
typing.Any |
to_dict()
def to_dict()
to_json()
def to_json(
encoder: collections.abc.Callable[[typing.Any], typing.Union[str, bytes, bytearray]],
to_dict_kwargs: typing.Any,
):
Parameter | Type |
---|---|
encoder |
collections.abc.Callable[[typing.Any], typing.Union[str, bytes, bytearray]] |
to_dict_kwargs |
typing.Any |
flytekit.types.schema.types.Enum
Create a collection of name/value pairs.
Example enumeration:
class Color(Enum): … RED = 1 … BLUE = 2 … GREEN = 3
Access them by:
- attribute access:
Color.RED <Color.RED: 1>
- value lookup:
Color(1) <Color.RED: 1>
- name lookup:
Color[‘RED’] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
len(Color) 3
list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
flytekit.types.schema.types.FlyteContext
This is an internal-facing context object, that most users will not have to deal with. It’s essentially a globally available grab bag of settings and objects that allows flytekit to do things like convert complex types, run and compile workflows, serialize Flyte entities, etc.
Even though this object as a current_context
function on it, it should not be called directly. Please use the
:py:class:flytekit.FlyteContextManager
object instead.
Please do not confuse this object with the :py:class:flytekit.ExecutionParameters
object.
def FlyteContext(
file_access: FileAccessProvider,
level: int,
flyte_client: Optional['friendly_client.SynchronousFlyteClient'],
compilation_state: Optional[CompilationState],
execution_state: Optional[ExecutionState],
serialization_settings: Optional[SerializationSettings],
in_a_condition: bool,
origin_stackframe: Optional[traceback.FrameSummary],
output_metadata_tracker: Optional[OutputMetadataTracker],
worker_queue: Optional[Controller],
):
Parameter | Type |
---|---|
file_access |
FileAccessProvider |
level |
int |
flyte_client |
Optional['friendly_client.SynchronousFlyteClient'] |
compilation_state |
Optional[CompilationState] |
execution_state |
Optional[ExecutionState] |
serialization_settings |
Optional[SerializationSettings] |
in_a_condition |
bool |
origin_stackframe |
Optional[traceback.FrameSummary] |
output_metadata_tracker |
Optional[OutputMetadataTracker] |
worker_queue |
Optional[Controller] |
Methods
Method | Description |
---|---|
current_context() |
This method exists only to maintain backwards compatibility |
enter_conditional_section() |
None |
get_deck() |
Returns the deck that was created as part of the last execution |
get_origin_stackframe_repr() |
None |
new_builder() |
None |
new_compilation_state() |
Creates and returns a default compilation state |
new_execution_state() |
Creates and returns a new default execution state |
set_stackframe() |
None |
with_client() |
None |
with_compilation_state() |
None |
with_execution_state() |
None |
with_file_access() |
None |
with_new_compilation_state() |
None |
with_output_metadata_tracker() |
None |
with_serialization_settings() |
None |
with_worker_queue() |
None |
current_context()
def current_context()
This method exists only to maintain backwards compatibility. Please use
FlyteContextManager.current_context()
instead.
Users of flytekit should be wary not to confuse the object returned from this function
with :py:func:flytekit.current_context
enter_conditional_section()
def enter_conditional_section()
get_deck()
def get_deck()
Returns the deck that was created as part of the last execution.
The return value depends on the execution environment. In a notebook, the return value is compatible with IPython.display and should be rendered in the notebook.
.. code-block:: python
with flytekit.new_context() as ctx: my_task(…) ctx.get_deck()
OR if you wish to explicitly display
.. code-block:: python
from IPython import display display(ctx.get_deck())
get_origin_stackframe_repr()
def get_origin_stackframe_repr()
new_builder()
def new_builder()
new_compilation_state()
def new_compilation_state(
prefix: str,
):
Creates and returns a default compilation state. For most of the code this should be the entrypoint of compilation, otherwise the code should always uses - with_compilation_state
Parameter | Type |
---|---|
prefix |
str |
new_execution_state()
def new_execution_state(
working_dir: Optional[os.PathLike],
):
Creates and returns a new default execution state. This should be used at the entrypoint of execution, in all other cases it is preferable to use with_execution_state
Parameter | Type |
---|---|
working_dir |
Optional[os.PathLike] |
set_stackframe()
def set_stackframe(
s: traceback.FrameSummary,
):
Parameter | Type |
---|---|
s |
traceback.FrameSummary |
with_client()
def with_client(
c: SynchronousFlyteClient,
):
Parameter | Type |
---|---|
c |
SynchronousFlyteClient |
with_compilation_state()
def with_compilation_state(
c: CompilationState,
):
Parameter | Type |
---|---|
c |
CompilationState |
with_execution_state()
def with_execution_state(
es: ExecutionState,
):
Parameter | Type |
---|---|
es |
ExecutionState |
with_file_access()
def with_file_access(
fa: FileAccessProvider,
):
Parameter | Type |
---|---|
fa |
FileAccessProvider |
with_new_compilation_state()
def with_new_compilation_state()
with_output_metadata_tracker()
def with_output_metadata_tracker(
t: OutputMetadataTracker,
):
Parameter | Type |
---|---|
t |
OutputMetadataTracker |
with_serialization_settings()
def with_serialization_settings(
ss: SerializationSettings,
):
Parameter | Type |
---|---|
ss |
SerializationSettings |
with_worker_queue()
def with_worker_queue(
wq: Controller,
):
Parameter | Type |
---|---|
wq |
Controller |
Properties
Property | Type | Description |
---|---|---|
user_space_params |
flytekit.types.schema.types.FlyteContextManager
FlyteContextManager manages the execution context within Flytekit. It holds global state of either compilation
or Execution. It is not thread-safe and can only be run as a single threaded application currently.
Context’s within Flytekit is useful to manage compilation state and execution state. Refer to CompilationState
and ExecutionState
for more information. FlyteContextManager provides a singleton stack to manage these contexts.
Typical usage is
.. code-block:: python
FlyteContextManager.initialize() with FlyteContextManager.with_context(o) as ctx: pass
If required - not recommended you can use
FlyteContextManager.push_context()
but correspondingly a pop_context should be called
FlyteContextManager.pop_context()
Methods
Method | Description |
---|---|
add_signal_handler() |
None |
current_context() |
None |
get_origin_stackframe() |
None |
initialize() |
Re-initializes the context and erases the entire context |
pop_context() |
None |
push_context() |
None |
size() |
None |
with_context() |
None |
add_signal_handler()
def add_signal_handler(
handler: typing.Callable[[int, FrameType], typing.Any],
):
Parameter | Type |
---|---|
handler |
typing.Callable[[int, FrameType], typing.Any] |
current_context()
def current_context()
get_origin_stackframe()
def get_origin_stackframe(
limit,
):
Parameter | Type |
---|---|
limit |
initialize()
def initialize()
Re-initializes the context and erases the entire context
pop_context()
def pop_context()
push_context()
def push_context(
ctx: FlyteContext,
f: Optional[traceback.FrameSummary],
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
f |
Optional[traceback.FrameSummary] |
size()
def size()
with_context()
def with_context(
b: FlyteContext.Builder,
):
Parameter | Type |
---|---|
b |
FlyteContext.Builder |
flytekit.types.schema.types.FlyteSchema
def FlyteSchema(
local_path: typing.Optional[str],
remote_path: typing.Optional[str],
supported_mode: SchemaOpenMode,
downloader: typing.Optional[typing.Callable],
):
Parameter | Type |
---|---|
local_path |
typing.Optional[str] |
remote_path |
typing.Optional[str] |
supported_mode |
SchemaOpenMode |
downloader |
typing.Optional[typing.Callable] |
Methods
Method | Description |
---|---|
as_readonly() |
None |
column_names() |
None |
columns() |
None |
deserialize_flyte_schema() |
None |
format() |
None |
from_dict() |
None |
from_json() |
None |
open() |
Returns a reader or writer depending on the mode of the object when created |
serialize_flyte_schema() |
None |
to_dict() |
None |
to_json() |
None |
as_readonly()
def as_readonly()
column_names()
def column_names()
columns()
def columns()
deserialize_flyte_schema()
def deserialize_flyte_schema(
args,
kwargs,
):
Parameter | Type |
---|---|
args |
*args |
kwargs |
**kwargs |
format()
def format()
from_dict()
def from_dict(
d,
dialect,
):
Parameter | Type |
---|---|
d |
|
dialect |
from_json()
def from_json(
data: typing.Union[str, bytes, bytearray],
decoder: collections.abc.Callable[[typing.Union[str, bytes, bytearray]], dict[typing.Any, typing.Any]],
from_dict_kwargs: typing.Any,
):
Parameter | Type |
---|---|
data |
typing.Union[str, bytes, bytearray] |
decoder |
collections.abc.Callable[[typing.Union[str, bytes, bytearray]], dict[typing.Any, typing.Any]] |
from_dict_kwargs |
typing.Any |
open()
def open(
dataframe_fmt: typing.Optional[type],
override_mode: typing.Optional[SchemaOpenMode],
):
Returns a reader or writer depending on the mode of the object when created. This mode can be overridden, but will depend on whether the override can be performed. For example, if the Object was created in a read-mode a “write mode” override is not allowed. if the object was created in write-mode, a read is allowed.
Parameter | Type |
---|---|
dataframe_fmt |
typing.Optional[type] |
override_mode |
typing.Optional[SchemaOpenMode] |
serialize_flyte_schema()
def serialize_flyte_schema(
args,
kwargs,
):
Parameter | Type |
---|---|
args |
*args |
kwargs |
**kwargs |
to_dict()
def to_dict()
to_json()
def to_json(
encoder: collections.abc.Callable[[typing.Any], typing.Union[str, bytes, bytearray]],
to_dict_kwargs: typing.Any,
):
Parameter | Type |
---|---|
encoder |
collections.abc.Callable[[typing.Any], typing.Union[str, bytes, bytearray]] |
to_dict_kwargs |
typing.Any |
Properties
Property | Type | Description |
---|---|---|
local_path | ||
supported_mode |
flytekit.types.schema.types.FlyteSchemaTransformer
Base transformer type that should be implemented for every python native type that can be handled by flytekit
def FlyteSchemaTransformer()
Methods
Method | Description |
---|---|
assert_type() |
None |
async_to_literal() |
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type |
async_to_python_value() |
Converts the given Literal to a Python Type |
dict_to_flyte_schema() |
None |
from_binary_idl() |
If the input is from flytekit, the Life Cycle will be as follows: |
from_generic_idl() |
If the input is from Flyte Console, the Life Cycle will be as follows: |
get_literal_type() |
Converts the python type to a Flyte LiteralType |
guess_python_type() |
Converts the Flyte LiteralType to a python object type |
isinstance_generic() |
None |
to_html() |
Converts any python val (dataframe, int, float) to a html string, and it will be wrapped in the HTML div |
to_literal() |
Converts a given python_val to a Flyte Literal, assuming the given python_val matches the declared python_type |
to_python_value() |
Converts the given Literal to a Python Type |
assert_type()
def assert_type(
t: Type[FlyteSchema],
v: typing.Any,
):
Parameter | Type |
---|---|
t |
Type[FlyteSchema] |
v |
typing.Any |
async_to_literal()
def async_to_literal(
ctx: FlyteContext,
python_val: FlyteSchema,
python_type: Type[FlyteSchema],
expected: LiteralType,
):
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 |
---|---|
ctx |
FlyteContext |
python_val |
FlyteSchema |
python_type |
Type[FlyteSchema] |
expected |
LiteralType |
async_to_python_value()
def async_to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type[FlyteSchema],
):
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type[FlyteSchema] |
dict_to_flyte_schema()
def dict_to_flyte_schema(
dict_obj: typing.Dict[str, str],
expected_python_type: Type[FlyteSchema],
):
Parameter | Type |
---|---|
dict_obj |
typing.Dict[str, str] |
expected_python_type |
Type[FlyteSchema] |
from_binary_idl()
def from_binary_idl(
binary_idl_object: Binary,
expected_python_type: Type[FlyteSchema],
):
If the input is from flytekit, the Life Cycle will be as follows:
Life Cycle: binary IDL -> resolved binary -> bytes -> expected Python object (flytekit customized (propeller processing) (flytekit binary IDL) (flytekit customized serialization) deserialization)
Example Code: @dataclass class DC: fs: FlyteSchema
@workflow def wf(dc: DC): t_fs(dc.fs)
Note:
- The deserialization is the same as put a flyte schema in a dataclass, which will deserialize by the mashumaro’s API.
Related PR:
- Title: Override Dataclass Serialization/Deserialization Behavior for FlyteTypes via Mashumaro
- Link: https://github.com/flyteorg/flytekit/pull/2554
Parameter | Type |
---|---|
binary_idl_object |
Binary |
expected_python_type |
Type[FlyteSchema] |
from_generic_idl()
def from_generic_idl(
generic: Struct,
expected_python_type: Type[FlyteSchema],
):
If the input is from Flyte Console, the Life Cycle will be as follows:
Life Cycle: json str -> protobuf struct -> resolved protobuf struct -> expected Python object (console user input) (console output) (propeller) (flytekit customized deserialization)
Example Code: @dataclass class DC: fs: FlyteSchema
@workflow def wf(dc: DC): t_fs(dc.fs)
Note:
- The deserialization is the same as put a flyte schema in a dataclass, which will deserialize by the mashumaro’s API.
Related PR:
- Title: Override Dataclass Serialization/Deserialization Behavior for FlyteTypes via Mashumaro
- Link: https://github.com/flyteorg/flytekit/pull/2554
Parameter | Type |
---|---|
generic |
Struct |
expected_python_type |
Type[FlyteSchema] |
get_literal_type()
def get_literal_type(
t: Type[FlyteSchema],
):
Converts the python type to a Flyte LiteralType
Parameter | Type |
---|---|
t |
Type[FlyteSchema] |
guess_python_type()
def guess_python_type(
literal_type: LiteralType,
):
Converts the Flyte LiteralType to a python object type.
Parameter | Type |
---|---|
literal_type |
LiteralType |
isinstance_generic()
def isinstance_generic(
obj,
generic_alias,
):
Parameter | Type |
---|---|
obj |
|
generic_alias |
to_html()
def to_html(
ctx: FlyteContext,
python_val: T,
expected_python_type: Type[T],
):
Converts any python val (dataframe, int, float) to a html string, and it will be wrapped in the HTML div
Parameter | Type |
---|---|
ctx |
FlyteContext |
python_val |
T |
expected_python_type |
Type[T] |
to_literal()
def to_literal(
ctx: FlyteContext,
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
):
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 |
---|---|
ctx |
FlyteContext |
python_val |
typing.Any |
python_type |
Type[T] |
expected |
LiteralType |
to_python_value()
def to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type[T],
):
Converts the given Literal to a Python Type. If the conversion cannot be done an AssertionError should be raised
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type[T] |
Properties
Property | Type | Description |
---|---|---|
is_async | ||
name | ||
python_type | ||
type_assertions_enabled |
flytekit.types.schema.types.Literal
def Literal(
scalar: typing.Optional[flytekit.models.literals.Scalar],
collection: typing.Optional[flytekit.models.literals.LiteralCollection],
map: typing.Optional[flytekit.models.literals.LiteralMap],
hash: typing.Optional[str],
metadata: typing.Optional[typing.Dict[str, str]],
offloaded_metadata: typing.Optional[flytekit.models.literals.LiteralOffloadedMetadata],
):
This IDL message represents a literal value in the Flyte ecosystem.
Parameter | Type |
---|---|
scalar |
typing.Optional[flytekit.models.literals.Scalar] |
collection |
typing.Optional[flytekit.models.literals.LiteralCollection] |
map |
typing.Optional[flytekit.models.literals.LiteralMap] |
hash |
typing.Optional[str] |
metadata |
typing.Optional[typing.Dict[str, str]] |
offloaded_metadata |
typing.Optional[flytekit.models.literals.LiteralOffloadedMetadata] |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
set_metadata() |
Note: This is a mutation on the literal |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
pb2_object: flyteidl.core.literals_pb2.Literal,
):
Parameter | Type |
---|---|
pb2_object |
flyteidl.core.literals_pb2.Literal |
serialize_to_string()
def serialize_to_string()
set_metadata()
def set_metadata(
metadata: typing.Dict[str, str],
):
Note: This is a mutation on the literal
Parameter | Type |
---|---|
metadata |
typing.Dict[str, str] |
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
collection | ||
hash | ||
is_empty | ||
map | ||
metadata | ||
offloaded_metadata | ||
scalar | ||
value |
flytekit.types.schema.types.LiteralType
def LiteralType(
simple,
schema,
collection_type,
map_value_type,
blob,
enum_type,
union_type,
structured_dataset_type,
metadata,
structure,
annotation,
):
This is a oneof message, only one of the kwargs may be set, representing one of the Flyte types.
Parameter | Type |
---|---|
simple |
|
schema |
|
collection_type |
|
map_value_type |
|
blob |
|
enum_type |
|
union_type |
|
structured_dataset_type |
|
metadata |
|
structure |
|
annotation |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
proto,
):
Parameter | Type |
---|---|
proto |
serialize_to_string()
def serialize_to_string()
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
annotation | ||
blob | ||
collection_type | ||
enum_type | ||
is_empty | ||
map_value_type | ||
metadata | ||
schema | ||
simple | ||
structure | ||
structured_dataset_type | ||
union_type |
flytekit.types.schema.types.LocalIOSchemaReader
Base SchemaReader to handle any readers (that can manage their own IO or otherwise) Use the simplified base LocalIOSchemaReader for non distributed dataframes
def LocalIOSchemaReader(
from_path: str,
cols: typing.Optional[typing.Dict[str, type]],
fmt: SchemaFormat,
):
Parameter | Type |
---|---|
from_path |
str |
cols |
typing.Optional[typing.Dict[str, type]] |
fmt |
SchemaFormat |
Methods
Method | Description |
---|---|
all() |
None |
iter() |
None |
all()
def all(
kwargs,
):
Parameter | Type |
---|---|
kwargs |
**kwargs |
iter()
def iter(
kwargs,
):
Parameter | Type |
---|---|
kwargs |
**kwargs |
Properties
Property | Type | Description |
---|---|---|
column_names | ||
from_path |
flytekit.types.schema.types.LocalIOSchemaWriter
Abstract base class for generic types.
On Python 3.12 and newer, generic classes implicitly inherit from Generic when they declare a parameter list after the class’s name::
class Mapping[KT, VT]: def getitem(self, key: KT) -> VT: …
Etc.
On older versions of Python, however, generic classes have to explicitly inherit from Generic.
After a class has been declared to be generic, it can then be used as follows::
def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
def LocalIOSchemaWriter(
to_local_path: str,
cols: typing.Optional[typing.Dict[str, type]],
fmt: SchemaFormat,
):
Parameter | Type |
---|---|
to_local_path |
str |
cols |
typing.Optional[typing.Dict[str, type]] |
fmt |
SchemaFormat |
Methods
Method | Description |
---|---|
write() |
None |
write()
def write(
dfs,
kwargs,
):
Parameter | Type |
---|---|
dfs |
|
kwargs |
**kwargs |
Properties
Property | Type | Description |
---|---|---|
column_names | ||
to_path |
flytekit.types.schema.types.Path
PurePath subclass that can make system calls.
Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.
def Path(
args,
kwargs,
):
Parameter | Type |
---|---|
args |
*args |
kwargs |
**kwargs |
Methods
Method | Description |
---|---|
absolute() |
Return an absolute version of this path by prepending the current |
as_posix() |
Return the string representation of the path with forward (/) |
as_uri() |
Return the path as a ‘file’ URI |
chmod() |
Change the permissions of the path, like os |
cwd() |
Return a new path pointing to the current working directory |
exists() |
Whether this path exists |
expanduser() |
Return a new path with expanded ~ and ~user constructs |
glob() |
Iterate over this subtree and yield all existing files (of any |
group() |
Return the group name of the file gid |
hardlink_to() |
Make this path a hard link pointing to the same file as target |
home() |
Return a new path pointing to the user’s home directory (as |
is_absolute() |
True if the path is absolute (has both a root and, if applicable, |
is_block_device() |
Whether this path is a block device |
is_char_device() |
Whether this path is a character device |
is_dir() |
Whether this path is a directory |
is_fifo() |
Whether this path is a FIFO |
is_file() |
Whether this path is a regular file (also True for symlinks pointing |
is_junction() |
Whether this path is a junction |
is_mount() |
Check if this path is a mount point |
is_relative_to() |
Return True if the path is relative to another path or False |
is_reserved() |
Return True if the path contains one of the special names reserved |
is_socket() |
Whether this path is a socket |
is_symlink() |
Whether this path is a symbolic link |
iterdir() |
Yield path objects of the directory contents |
joinpath() |
Combine this path with one or several arguments, and return a |
lchmod() |
Like chmod(), except if the path points to a symlink, the symlink’s |
lstat() |
Like stat(), except if the path points to a symlink, the symlink’s |
match() |
Return True if this path matches the given pattern |
mkdir() |
Create a new directory at this given path |
open() |
Open the file pointed to by this path and return a file object, as |
owner() |
Return the login name of the file owner |
read_bytes() |
Open the file in bytes mode, read it, and close the file |
read_text() |
Open the file in text mode, read it, and close the file |
readlink() |
Return the path to which the symbolic link points |
relative_to() |
Return the relative path to another path identified by the passed |
rename() |
Rename this path to the target path |
replace() |
Rename this path to the target path, overwriting if that path exists |
resolve() |
Make the path absolute, resolving all symlinks on the way and also |
rglob() |
Recursively yield all existing files (of any kind, including |
rmdir() |
Remove this directory |
samefile() |
Return whether other_path is the same or not as this file |
stat() |
Return the result of the stat() system call on this path, like |
symlink_to() |
Make this path a symlink pointing to the target path |
touch() |
Create this file with the given access mode, if it doesn’t exist |
unlink() |
Remove this file or link |
walk() |
Walk the directory tree from this directory, similar to os |
with_name() |
Return a new path with the file name changed |
with_segments() |
Construct a new path object from any number of path-like objects |
with_stem() |
Return a new path with the stem changed |
with_suffix() |
Return a new path with the file suffix changed |
write_bytes() |
Open the file in bytes mode, write to it, and close the file |
write_text() |
Open the file in text mode, write to it, and close the file |
absolute()
def absolute()
Return an absolute version of this path by prepending the current working directory. No normalization or symlink resolution is performed.
Use resolve() to get the canonical path to a file.
as_posix()
def as_posix()
Return the string representation of the path with forward (/) slashes.
as_uri()
def as_uri()
Return the path as a ‘file’ URI.
chmod()
def chmod(
mode,
follow_symlinks,
):
Change the permissions of the path, like os.chmod().
Parameter | Type |
---|---|
mode |
|
follow_symlinks |
cwd()
def cwd()
Return a new path pointing to the current working directory.
exists()
def exists(
follow_symlinks,
):
Whether this path exists.
This method normally follows symlinks; to check whether a symlink exists, add the argument follow_symlinks=False.
Parameter | Type |
---|---|
follow_symlinks |
expanduser()
def expanduser()
Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)
glob()
def glob(
pattern,
case_sensitive,
):
Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.
Parameter | Type |
---|---|
pattern |
|
case_sensitive |
group()
def group()
Return the group name of the file gid.
hardlink_to()
def hardlink_to(
target,
):
Make this path a hard link pointing to the same file as target.
Note the order of arguments (self, target) is the reverse of os.link’s.
Parameter | Type |
---|---|
target |
home()
def home()
Return a new path pointing to the user’s home directory (as returned by os.path.expanduser(’~’)).
is_absolute()
def is_absolute()
True if the path is absolute (has both a root and, if applicable, a drive).
is_block_device()
def is_block_device()
Whether this path is a block device.
is_char_device()
def is_char_device()
Whether this path is a character device.
is_dir()
def is_dir()
Whether this path is a directory.
is_fifo()
def is_fifo()
Whether this path is a FIFO.
is_file()
def is_file()
Whether this path is a regular file (also True for symlinks pointing to regular files).
is_junction()
def is_junction()
Whether this path is a junction.
is_mount()
def is_mount()
Check if this path is a mount point
is_relative_to()
def is_relative_to(
other,
_deprecated,
):
Return True if the path is relative to another path or False.
Parameter | Type |
---|---|
other |
|
_deprecated |
is_reserved()
def is_reserved()
Return True if the path contains one of the special names reserved by the system, if any.
is_socket()
def is_socket()
Whether this path is a socket.
is_symlink()
def is_symlink()
Whether this path is a symbolic link.
iterdir()
def iterdir()
Yield path objects of the directory contents.
The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.
joinpath()
def joinpath(
pathsegments,
):
Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored).
Parameter | Type |
---|---|
pathsegments |
lchmod()
def lchmod(
mode,
):
Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.
Parameter | Type |
---|---|
mode |
lstat()
def lstat()
Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.
match()
def match(
path_pattern,
case_sensitive,
):
Return True if this path matches the given pattern.
Parameter | Type |
---|---|
path_pattern |
|
case_sensitive |
mkdir()
def mkdir(
mode,
parents,
exist_ok,
):
Create a new directory at this given path.
Parameter | Type |
---|---|
mode |
|
parents |
|
exist_ok |
open()
def open(
mode,
buffering,
encoding,
errors,
newline,
):
Open the file pointed to by this path and return a file object, as the built-in open() function does.
Parameter | Type |
---|---|
mode |
|
buffering |
|
encoding |
|
errors |
|
newline |
owner()
def owner()
Return the login name of the file owner.
read_bytes()
def read_bytes()
Open the file in bytes mode, read it, and close the file.
read_text()
def read_text(
encoding,
errors,
):
Open the file in text mode, read it, and close the file.
Parameter | Type |
---|---|
encoding |
|
errors |
readlink()
def readlink()
Return the path to which the symbolic link points.
relative_to()
def relative_to(
other,
_deprecated,
walk_up,
):
Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not related to the other path), raise ValueError.
The walk_up parameter controls whether ..
may be used to resolve
the path.
Parameter | Type |
---|---|
other |
|
_deprecated |
|
walk_up |
rename()
def rename(
target,
):
Rename this path to the target path.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
Parameter | Type |
---|---|
target |
replace()
def replace(
target,
):
Rename this path to the target path, overwriting if that path exists.
The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.
Returns the new Path instance pointing to the target path.
Parameter | Type |
---|---|
target |
resolve()
def resolve(
strict,
):
Make the path absolute, resolving all symlinks on the way and also normalizing it.
Parameter | Type |
---|---|
strict |
rglob()
def rglob(
pattern,
case_sensitive,
):
Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.
Parameter | Type |
---|---|
pattern |
|
case_sensitive |
rmdir()
def rmdir()
Remove this directory. The directory must be empty.
samefile()
def samefile(
other_path,
):
Return whether other_path is the same or not as this file (as returned by os.path.samefile()).
Parameter | Type |
---|---|
other_path |
stat()
def stat(
follow_symlinks,
):
Return the result of the stat() system call on this path, like os.stat() does.
Parameter | Type |
---|---|
follow_symlinks |
symlink_to()
def symlink_to(
target,
target_is_directory,
):
Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.
Parameter | Type |
---|---|
target |
|
target_is_directory |
touch()
def touch(
mode,
exist_ok,
):
Create this file with the given access mode, if it doesn’t exist.
Parameter | Type |
---|---|
mode |
|
exist_ok |
unlink()
def unlink(
missing_ok,
):
Remove this file or link. If the path is a directory, use rmdir() instead.
Parameter | Type |
---|---|
missing_ok |
walk()
def walk(
top_down,
on_error,
follow_symlinks,
):
Walk the directory tree from this directory, similar to os.walk().
Parameter | Type |
---|---|
top_down |
|
on_error |
|
follow_symlinks |
with_name()
def with_name(
name,
):
Return a new path with the file name changed.
Parameter | Type |
---|---|
name |
with_segments()
def with_segments(
pathsegments,
):
Construct a new path object from any number of path-like objects.
Subclasses may override this method to customize how new path objects
are created from methods like iterdir()
.
Parameter | Type |
---|---|
pathsegments |
with_stem()
def with_stem(
stem,
):
Return a new path with the stem changed.
Parameter | Type |
---|---|
stem |
with_suffix()
def with_suffix(
suffix,
):
Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
Parameter | Type |
---|---|
suffix |
write_bytes()
def write_bytes(
data,
):
Open the file in bytes mode, write to it, and close the file.
Parameter | Type |
---|---|
data |
write_text()
def write_text(
data,
encoding,
errors,
newline,
):
Open the file in text mode, write to it, and close the file.
Parameter | Type |
---|---|
data |
|
encoding |
|
errors |
|
newline |
Properties
Property | Type | Description |
---|---|---|
anchor | ||
drive | ||
name | ||
parent | ||
parents | ||
parts | ||
root | ||
stem | ||
suffix | ||
suffixes |
flytekit.types.schema.types.Scalar
def Scalar(
primitive: typing.Optional[flytekit.models.literals.Primitive],
blob: typing.Optional[flytekit.models.literals.Blob],
binary: typing.Optional[flytekit.models.literals.Binary],
schema: typing.Optional[flytekit.models.literals.Schema],
union: typing.Optional[flytekit.models.literals.Union],
none_type: typing.Optional[flytekit.models.literals.Void],
error: typing.Optional[flytekit.models.types.Error],
generic: typing.Optional[google.protobuf.struct_pb2.Struct],
structured_dataset: typing.Optional[flytekit.models.literals.StructuredDataset],
):
Scalar wrapper around Flyte types. Only one can be specified.
Parameter | Type |
---|---|
primitive |
typing.Optional[flytekit.models.literals.Primitive] |
blob |
typing.Optional[flytekit.models.literals.Blob] |
binary |
typing.Optional[flytekit.models.literals.Binary] |
schema |
typing.Optional[flytekit.models.literals.Schema] |
union |
typing.Optional[flytekit.models.literals.Union] |
none_type |
typing.Optional[flytekit.models.literals.Void] |
error |
typing.Optional[flytekit.models.types.Error] |
generic |
typing.Optional[google.protobuf.struct_pb2.Struct] |
structured_dataset |
typing.Optional[flytekit.models.literals.StructuredDataset] |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
pb2_object,
):
Parameter | Type |
---|---|
pb2_object |
serialize_to_string()
def serialize_to_string()
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
binary | ||
blob | ||
error | ||
generic | ||
is_empty | ||
none_type | ||
primitive | ||
schema | ||
structured_dataset | ||
union | ||
value |
flytekit.types.schema.types.Schema
def Schema(
uri,
type,
):
A strongly typed schema that defines the interface of data retrieved from the underlying storage medium.
Parameter | Type |
---|---|
uri |
|
type |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
pb2_object,
):
Parameter | Type |
---|---|
pb2_object |
serialize_to_string()
def serialize_to_string()
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
is_empty | ||
type | ||
uri |
flytekit.types.schema.types.SchemaEngine
This is the core Engine that handles all schema sub-systems. All schema types needs to be registered with this to allow direct support for that type in FlyteSchema. e.g. of possible supported types are Pandas.DataFrame, Spark.DataFrame, Vaex.DataFrame, etc.
Methods
Method | Description |
---|---|
get_handler() |
None |
register_handler() |
Register a new handler that can create a SchemaReader and SchemaWriter for the expected type |
get_handler()
def get_handler(
t: Type,
):
Parameter | Type |
---|---|
t |
Type |
register_handler()
def register_handler(
h: SchemaHandler,
):
Register a new handler that can create a SchemaReader and SchemaWriter for the expected type.
Parameter | Type |
---|---|
h |
SchemaHandler |
flytekit.types.schema.types.SchemaFormat
Represents the schema storage format (at rest). Currently only parquet is supported
flytekit.types.schema.types.SchemaHandler
def SchemaHandler(
name: str,
object_type: Type,
reader: Type[SchemaReader],
writer: Type[SchemaWriter],
handles_remote_io: bool,
):
Parameter | Type |
---|---|
name |
str |
object_type |
Type |
reader |
Type[SchemaReader] |
writer |
Type[SchemaWriter] |
handles_remote_io |
bool |
flytekit.types.schema.types.SchemaOpenMode
Create a collection of name/value pairs.
Example enumeration:
class Color(Enum): … RED = 1 … BLUE = 2 … GREEN = 3
Access them by:
- attribute access:
Color.RED <Color.RED: 1>
- value lookup:
Color(1) <Color.RED: 1>
- name lookup:
Color[‘RED’] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
len(Color) 3
list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
flytekit.types.schema.types.SchemaReader
Base SchemaReader to handle any readers (that can manage their own IO or otherwise) Use the simplified base LocalIOSchemaReader for non distributed dataframes
def SchemaReader(
from_path: str,
cols: typing.Optional[typing.Dict[str, type]],
fmt: SchemaFormat,
):
Parameter | Type |
---|---|
from_path |
str |
cols |
typing.Optional[typing.Dict[str, type]] |
fmt |
SchemaFormat |
Methods
Method | Description |
---|---|
all() |
None |
iter() |
None |
all()
def all(
kwargs,
):
Parameter | Type |
---|---|
kwargs |
**kwargs |
iter()
def iter(
kwargs,
):
Parameter | Type |
---|---|
kwargs |
**kwargs |
Properties
Property | Type | Description |
---|---|---|
column_names | ||
from_path |
flytekit.types.schema.types.SchemaType
def SchemaType(
columns,
):
Parameter | Type |
---|---|
columns |
Methods
Method | Description |
---|---|
from_flyte_idl() |
|
serialize_to_string() |
None |
short_string() |
|
to_flyte_idl() |
|
verbose_string() |
from_flyte_idl()
def from_flyte_idl(
proto,
):
Parameter | Type |
---|---|
proto |
serialize_to_string()
def serialize_to_string()
short_string()
def short_string()
to_flyte_idl()
def to_flyte_idl()
verbose_string()
def verbose_string()
Properties
Property | Type | Description |
---|---|---|
columns | ||
is_empty |
flytekit.types.schema.types.SchemaWriter
Abstract base class for generic types.
On Python 3.12 and newer, generic classes implicitly inherit from Generic when they declare a parameter list after the class’s name::
class Mapping[KT, VT]: def getitem(self, key: KT) -> VT: …
Etc.
On older versions of Python, however, generic classes have to explicitly inherit from Generic.
After a class has been declared to be generic, it can then be used as follows::
def lookup_name[KT, VT](mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default
def SchemaWriter(
to_path: str,
cols: typing.Optional[typing.Dict[str, type]],
fmt: SchemaFormat,
):
Parameter | Type |
---|---|
to_path |
str |
cols |
typing.Optional[typing.Dict[str, type]] |
fmt |
SchemaFormat |
Methods
Method | Description |
---|---|
write() |
None |
write()
def write(
dfs,
kwargs,
):
Parameter | Type |
---|---|
dfs |
|
kwargs |
**kwargs |
Properties
Property | Type | Description |
---|---|---|
column_names | ||
to_path |
flytekit.types.schema.types.SerializableType
flytekit.types.schema.types.Struct
A ProtocolMessage
Methods
Method | Description |
---|---|
get_or_create_list() |
Returns a list for this key, creating if it didn’t exist already |
get_or_create_struct() |
Returns a struct for this key, creating if it didn’t exist already |
items() |
None |
keys() |
None |
update() |
None |
values() |
None |
get_or_create_list()
def get_or_create_list(
key,
):
Returns a list for this key, creating if it didn’t exist already.
Parameter | Type |
---|---|
key |
get_or_create_struct()
def get_or_create_struct(
key,
):
Returns a struct for this key, creating if it didn’t exist already.
Parameter | Type |
---|---|
key |
items()
def items()
keys()
def keys()
update()
def update(
dictionary,
):
Parameter | Type |
---|---|
dictionary |
values()
def values()
flytekit.types.schema.types.TypeEngine
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
Method | Description |
---|---|
async_to_literal() |
Converts a python value of a given type and expected LiteralType into a resolved Literal value |
async_to_python_value() |
None |
calculate_hash() |
None |
dict_to_literal_map() |
None |
dict_to_literal_map_pb() |
None |
get_available_transformers() |
Returns all python types for which transformers are available |
get_transformer() |
Implements a recursive search for the transformer |
guess_python_type() |
Transforms a flyte-specific LiteralType to a regular python value |
guess_python_types() |
Transforms a dictionary of flyte-specific Variable objects to a dictionary of regular python values |
lazy_import_transformers() |
Only load the transformers if needed |
literal_map_to_kwargs() |
None |
named_tuple_to_variable_map() |
Converts a python-native NamedTuple to a flyte-specific VariableMap of named literals |
register() |
This should be used for all types that respond with the right type annotation when you use type( |
register_additional_type() |
None |
register_restricted_type() |
None |
to_html() |
None |
to_literal() |
The current dance is because we are allowing users to call from an async function, this synchronous |
to_literal_checks() |
None |
to_literal_type() |
Converts a python type into a flyte specific LiteralType |
to_python_value() |
Converts a Literal value with an expected python type into a python value |
unwrap_offloaded_literal() |
None |
async_to_literal()
def async_to_literal(
ctx: FlyteContext,
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
):
Converts a python value of a given type and expected LiteralType
into a resolved Literal
value.
Parameter | Type |
---|---|
ctx |
FlyteContext |
python_val |
typing.Any |
python_type |
Type[T] |
expected |
LiteralType |
async_to_python_value()
def async_to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type,
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type |
calculate_hash()
def calculate_hash(
python_val: typing.Any,
python_type: Type[T],
):
Parameter | Type |
---|---|
python_val |
typing.Any |
python_type |
Type[T] |
dict_to_literal_map()
def dict_to_literal_map(
ctx: FlyteContext,
d: typing.Dict[str, typing.Any],
type_hints: Optional[typing.Dict[str, type]],
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
d |
typing.Dict[str, typing.Any] |
type_hints |
Optional[typing.Dict[str, type]] |
dict_to_literal_map_pb()
def dict_to_literal_map_pb(
ctx: FlyteContext,
d: typing.Dict[str, typing.Any],
type_hints: Optional[typing.Dict[str, type]],
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
d |
typing.Dict[str, typing.Any] |
type_hints |
Optional[typing.Dict[str, type]] |
get_available_transformers()
def get_available_transformers()
Returns all python types for which transformers are available
get_transformer()
def get_transformer(
python_type: Type,
):
Implements a recursive search for the transformer.
Parameter | Type |
---|---|
python_type |
Type |
guess_python_type()
def guess_python_type(
flyte_type: LiteralType,
):
Transforms a flyte-specific LiteralType
to a regular python value.
Parameter | Type |
---|---|
flyte_type |
LiteralType |
guess_python_types()
def guess_python_types(
flyte_variable_dict: typing.Dict[str, _interface_models.Variable],
):
Transforms a dictionary of flyte-specific Variable
objects to a dictionary of regular python values.
Parameter | Type |
---|---|
flyte_variable_dict |
typing.Dict[str, _interface_models.Variable] |
lazy_import_transformers()
def lazy_import_transformers()
Only load the transformers if needed.
literal_map_to_kwargs()
def literal_map_to_kwargs(
ctx: FlyteContext,
lm: LiteralMap,
python_types: typing.Optional[typing.Dict[str, type]],
literal_types: typing.Optional[typing.Dict[str, _interface_models.Variable]],
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
lm |
LiteralMap |
python_types |
typing.Optional[typing.Dict[str, type]] |
literal_types |
typing.Optional[typing.Dict[str, _interface_models.Variable]] |
named_tuple_to_variable_map()
def named_tuple_to_variable_map(
t: typing.NamedTuple,
):
Converts a python-native NamedTuple
to a flyte-specific VariableMap of named literals.
Parameter | Type |
---|---|
t |
typing.NamedTuple |
register()
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 |
---|---|
transformer |
TypeTransformer |
additional_types |
Optional[typing.List[Type]] |
register_additional_type()
def register_additional_type(
transformer: TypeTransformer[T],
additional_type: Type[T],
override,
):
Parameter | Type |
---|---|
transformer |
TypeTransformer[T] |
additional_type |
Type[T] |
override |
register_restricted_type()
def register_restricted_type(
name: str,
type: Type[T],
):
Parameter | Type |
---|---|
name |
str |
type |
Type[T] |
to_html()
def to_html(
ctx: FlyteContext,
python_val: typing.Any,
expected_python_type: Type[typing.Any],
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
python_val |
typing.Any |
expected_python_type |
Type[typing.Any] |
to_literal()
def to_literal(
ctx: FlyteContext,
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
):
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.
Parameter | Type |
---|---|
ctx |
FlyteContext |
python_val |
typing.Any |
python_type |
Type[T] |
expected |
LiteralType |
to_literal_checks()
def to_literal_checks(
python_val: typing.Any,
python_type: Type[T],
expected: LiteralType,
):
Parameter | Type |
---|---|
python_val |
typing.Any |
python_type |
Type[T] |
expected |
LiteralType |
to_literal_type()
def to_literal_type(
python_type: Type[T],
):
Converts a python type into a flyte specific LiteralType
Parameter | Type |
---|---|
python_type |
Type[T] |
to_python_value()
def to_python_value(
ctx: FlyteContext,
lv: Literal,
expected_python_type: Type,
):
Converts a Literal value with an expected python type into a python value.
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
expected_python_type |
Type |
unwrap_offloaded_literal()
def unwrap_offloaded_literal(
ctx: FlyteContext,
lv: Literal,
):
Parameter | Type |
---|---|
ctx |
FlyteContext |
lv |
Literal |
flytekit.types.schema.types.TypeTransformerFailedError
Inappropriate argument type.