2.0.0b1

flyte.models

Directory

Classes

Class Description
ActionID A class representing the ID of an Action, nested within a Run.
Checkpoints A class representing the checkpoints for a task.
CodeBundle A class representing a code bundle for a task.
GroupData
NativeInterface A class representing the native interface for a task.
RawDataPath A class representing the raw data path for a task.
SerializationContext This object holds serialization time contextual information, that can be used when serializing the task and.
TaskContext A context class to hold the current task executions context.

Methods

Method Description
generate_random_name() Generate a random name for the task.

Variables

Property Type Description
TYPE_CHECKING bool

Methods

generate_random_name()

def generate_random_name()

Generate a random name for the task. This is used to create unique names for tasks. TODO we can use unique-namer in the future, for now its just guids

flyte.models.ActionID

A class representing the ID of an Action, nested within a Run. This is used to identify a specific action on a task.

class ActionID(
    name: str,
    run_name: str | None,
    project: str | None,
    domain: str | None,
    org: str | None,
)
Parameter Type
name str
run_name str | None
project str | None
domain str | None
org str | None

Methods

Method Description
create_random()
new_sub_action() Create a new sub-run with the given name.
new_sub_action_from() Make a deterministic name.

create_random()

def create_random()

new_sub_action()

def new_sub_action(
    name: str | None,
) -> ActionID

Create a new sub-run with the given name. If name is None, a random name will be generated.

Parameter Type
name str | None

new_sub_action_from()

def new_sub_action_from(
    task_call_seq: int,
    task_hash: str,
    input_hash: str,
    group: str | None,
) -> ActionID

Make a deterministic name

Parameter Type
task_call_seq int
task_hash str
input_hash str
group str | None

flyte.models.Checkpoints

A class representing the checkpoints for a task. This is used to store the checkpoints for the task execution.

class Checkpoints(
    prev_checkpoint_path: str | None,
    checkpoint_path: str | None,
)
Parameter Type
prev_checkpoint_path str | None
checkpoint_path str | None

flyte.models.CodeBundle

A class representing a code bundle for a task. This is used to package the code and the inflation path. The code bundle computes the version of the code using the hash of the code.

class CodeBundle(
    computed_version: str,
    destination: str,
    tgz: str | None,
    pkl: str | None,
    downloaded_path: pathlib.Path | None,
)
Parameter Type
computed_version str
destination str
tgz str | None
pkl str | None
downloaded_path pathlib.Path | None

Methods

Method Description
with_downloaded_path() Create a new CodeBundle with the given downloaded path.

with_downloaded_path()

def with_downloaded_path(
    path: pathlib.Path,
) -> CodeBundle

Create a new CodeBundle with the given downloaded path.

Parameter Type
path pathlib.Path

flyte.models.GroupData

class GroupData(
    name: str,
)
Parameter Type
name str

flyte.models.NativeInterface

A class representing the native interface for a task. This is used to interact with the task and its execution context.

class NativeInterface(
    inputs: Dict[str, Tuple[Type, Any]],
    outputs: Dict[str, Type],
    docstring: Optional[Docstring],
    _remote_defaults: Optional[Dict[str, literals_pb2.Literal]],
)
Parameter Type
inputs Dict[str, Tuple[Type, Any]]
outputs Dict[str, Type]
docstring Optional[Docstring]
_remote_defaults Optional[Dict[str, literals_pb2.Literal]]

Methods

Method Description
convert_to_kwargs() Convert the given arguments to keyword arguments based on the native interface.
from_callable() Extract the native interface from the given function.
from_types() Create a new NativeInterface from the given types.
get_input_types() Get the input types for the task.
has_outputs() Check if the task has outputs.
num_required_inputs() Get the number of required inputs for the task.

convert_to_kwargs()

def convert_to_kwargs(
    args,
    kwargs,
) -> Dict[str, Any]

Convert the given arguments to keyword arguments based on the native interface. This is used to convert the arguments to the correct types for the task execution.

Parameter Type
args *args
kwargs **kwargs

from_callable()

def from_callable(
    func: Callable,
) -> NativeInterface

Extract the native interface from the given function. This is used to create a native interface for the task.

Parameter Type
func Callable

from_types()

def from_types(
    inputs: Dict[str, Tuple[Type, Type[_has_default] | Type[inspect._empty]]],
    outputs: Dict[str, Type],
    default_inputs: Optional[Dict[str, literals_pb2.Literal]],
) -> NativeInterface

Create a new NativeInterface from the given types. This is used to create a native interface for the task.

Parameter Type
inputs Dict[str, Tuple[Type, Type[_has_default] | Type[inspect._empty]]]
outputs Dict[str, Type]
default_inputs Optional[Dict[str, literals_pb2.Literal]]

get_input_types()

def get_input_types()

Get the input types for the task. This is used to get the types of the inputs for the task execution.

has_outputs()

def has_outputs()

Check if the task has outputs. This is used to determine if the task has outputs or not.

num_required_inputs()

def num_required_inputs()

Get the number of required inputs for the task. This is used to determine how many inputs are required for the task execution.

flyte.models.RawDataPath

A class representing the raw data path for a task. This is used to store the raw data for the task execution and also get mutations on the path.

class RawDataPath(
    path: str,
)
Parameter Type
path str

Methods

Method Description
from_local_folder() Create a new context attribute object, with local path given.
get_random_remote_path() Returns a random path for uploading a file/directory to.

from_local_folder()

def from_local_folder(
    local_folder: str | pathlib.Path | None,
) -> RawDataPath

Create a new context attribute object, with local path given. Will be created if it doesn’t exist. :return: Path to the temporary directory

Parameter Type
local_folder str | pathlib.Path | None

get_random_remote_path()

def get_random_remote_path(
    file_name: Optional[str],
) -> str

Returns a random path for uploading a file/directory to.

Parameter Type
file_name Optional[str]

flyte.models.SerializationContext

This object holds serialization time contextual information, that can be used when serializing the task and various parameters of a tasktemplate. This is only available when the task is being serialized and can be during a deployment or runtime.

class SerializationContext(
    version: str,
    project: str | None,
    domain: str | None,
    org: str | None,
    code_bundle: Optional[CodeBundle],
    input_path: str,
    output_path: str,
    image_cache: ImageCache | None,
    root_dir: Optional[pathlib.Path],
)
Parameter Type
version str
project str | None
domain str | None
org str | None
code_bundle Optional[CodeBundle]
input_path str
output_path str
image_cache ImageCache | None
root_dir Optional[pathlib.Path]

Methods

Method Description
get_entrypoint_path() Get the entrypoint path for the task.

get_entrypoint_path()

def get_entrypoint_path(
    interpreter_path: str,
) -> str

Get the entrypoint path for the task. This is used to determine the entrypoint for the task execution.

Parameter Type
interpreter_path str

flyte.models.TaskContext

A context class to hold the current task executions context. This can be used to access various contextual parameters in the task execution by the user.

class TaskContext(
    action: ActionID,
    version: str,
    raw_data_path: RawDataPath,
    output_path: str,
    run_base_dir: str,
    report: Report,
    group_data: GroupData | None,
    checkpoints: Checkpoints | None,
    code_bundle: CodeBundle | None,
    compiled_image_cache: ImageCache | None,
    data: Dict[str, Any],
    mode: Literal['local', 'remote', 'hybrid'],
)
Parameter Type
action ActionID
version str
raw_data_path RawDataPath
output_path str
run_base_dir str
report Report
group_data GroupData | None
checkpoints Checkpoints | None
code_bundle CodeBundle | None
compiled_image_cache ImageCache | None
data Dict[str, Any]
mode Literal['local', 'remote', 'hybrid']

Methods

Method Description
replace()

replace()

def replace(
    kwargs,
) -> TaskContext
Parameter Type
kwargs **kwargs