flyte.models
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. |
Property |
Type |
Description |
TYPE_CHECKING |
bool |
|
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
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 |
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 |
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 |
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 |
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 |
def with_downloaded_path(
path: pathlib.Path,
) -> CodeBundle
Create a new CodeBundle with the given downloaded path.
Parameter |
Type |
path |
pathlib.Path |
class GroupData(
name: str,
)
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]] |
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 |
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 |
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 the input types for the task. This is used to get the types of the inputs for the task execution.
Check if the task has outputs. This is used to determine if the task has outputs or not.
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.
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,
)
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 |
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] |
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] |
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 |
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'] |
def replace(
kwargs,
) -> TaskContext
Parameter |
Type |
kwargs |
**kwargs |