Skip to main content

Action

A class representing an action. It is used to manage the "execution" of a task and its state on the remote API.

Attributes

AttributeTypeDescription
pb2run_definition_pb2.ActionThis attribute stores the protobuf representation of the action, which is used to manage the execution and state of a task on the remote API.

Methods


listall()

@classmethod
def listall(
for_run_name: str,
in_phase: Tuple[ActionPhase | str, ...]| None = None,
sort_by: Tuple[str, Literal["asc", "desc"]]| None = None,
created_at: TimeFilter | None = None,
updated_at: TimeFilter | None = None
) - > Union[Iterator[[Action](action.md?sid=flyte_remote__action_action)], AsyncIterator[[Action](action.md?sid=flyte_remote__action_action)]]

Get all actions for a given run.

Parameters

NameTypeDescription
for_run_namestrThe name of the run.
in_phase`Tuple[ActionPhasestr, ...]
sort_by`Tuple[str, Literal["asc", "desc"]]None` = None
created_at`TimeFilterNone` = None
updated_at`TimeFilterNone` = None

Returns

TypeDescription
Union[Iterator[[Action](action.md?sid=flyte_remote__action_action)], AsyncIterator[[Action](action.md?sid=flyte_remote__action_action)]]An iterator of actions.

get()

@classmethod
def get(
uri: str | None = None,
run_name: str | None = None,
name: str | None = None
) - > [Action](action.md?sid=flyte_remote__action_action)

Get a run by its ID or name. If both are provided, the ID will take precedence.

Parameters

NameTypeDescription
uri`strNone` = None
run_name`strNone` = None
name`strNone` = None

Returns

TypeDescription
[Action](action.md?sid=flyte_remote__action_action)The Action object corresponding to the provided identifier.

phase()

@classmethod
def phase() - > [ActionPhase](../../models/actionphase.md?sid=flyte_models_actionphase)

Get the phase of the action.

Returns

TypeDescription
[ActionPhase](../../models/actionphase.md?sid=flyte_models_actionphase)The current execution phase as an ActionPhase enum

raw_phase()

@classmethod
def raw_phase() - > phase_pb2.ActionPhase

Get the raw phase of the action.

Returns

TypeDescription
phase_pb2.ActionPhaseThe raw protobuf representation of the action's phase.

name()

@classmethod
def name() - > str

Get the name of the action.

Returns

TypeDescription
strThe name of the action.

run_name()

@classmethod
def run_name() - > str

Get the name of the run.

Returns

TypeDescription
strThe name of the run associated with this action.

task_name()

@classmethod
def task_name() - > str | None

Get the name of the task.

Returns

TypeDescription
`strNone`

action_id()

@classmethod
def action_id() - > identifier_pb2.ActionIdentifier

Get the action ID.

Returns

TypeDescription
identifier_pb2.ActionIdentifierThe unique identifier for this action.

start_time()

@classmethod
def start_time() - > datetime

Get the start time of the action.

Returns

TypeDescription
datetimeThe UTC datetime when the action started.

abort()

@classmethod
def abort(
reason: str = "Manually aborted from the SDK."
) - > None

Aborts / Terminates the action.

Parameters

NameTypeDescription
reasonstr = "Manually aborted from the SDK."The reason for aborting the action.

Returns

TypeDescription
NoneNone

show_logs()

@classmethod
def show_logs(
attempt: int | None = None,
max_lines: int = 30,
show_ts: bool = False,
raw: bool = False,
filter_system: bool = False
) - > None

Display logs for the action.

Parameters

NameTypeDescription
attempt`intNone` = None
max_linesint = 30Maximum number of log lines to display in the viewer.
show_tsbool = FalseWhether to show timestamps with each log line.
rawbool = FalseIf True, print logs directly without the interactive viewer.
filter_systembool = FalseIf True, filter out system-generated log lines.

Returns

TypeDescription
NoneNone

get_logs()

@classmethod
def get_logs(
attempt: int | None = None,
filter_system: bool = False,
show_ts: bool = False
) - > AsyncGenerator[str, None]

Get logs for the action as an iterator of strings. Can be called synchronously (returns Iterator[str]) or asynchronously via .aio() (returns AsyncIterator[str]).

Parameters

NameTypeDescription
attempt`intNone` = None
filter_systembool = FalseIf True, filter out system-generated log lines.
show_tsbool = FalseIf True, prefix each line with an ISO-8601 timestamp.

Returns

TypeDescription
AsyncGenerator[str, None]An asynchronous generator that yields log lines as strings.

details()

@classmethod
def details() - > [ActionDetails](actiondetails.md?sid=flyte_remote__action_actiondetails)

Get the details of the action. This is a placeholder for getting the action details.

Returns

TypeDescription
[ActionDetails](actiondetails.md?sid=flyte_remote__action_actiondetails)The detailed information about the action.

watch()

@classmethod
def watch(
cache_data_on_done: bool = False,
wait_for: WaitFor = "terminal"
) - > AsyncGenerator[[ActionDetails](actiondetails.md?sid=flyte_remote__action_actiondetails), None]

Watch the action for updates, updating the internal Action state with latest details. This method updates both the cached details and the protobuf representation, ensuring that properties like phase reflect the current state.

Parameters

NameTypeDescription
cache_data_on_donebool = FalseIf True, caches output data when the action reaches a terminal state.
wait_forWaitFor = "terminal"Specifies the state to wait for before stopping the watch. Can be 'running', 'logs-ready', or 'terminal'.

Returns

TypeDescription
AsyncGenerator[[ActionDetails](actiondetails.md?sid=flyte_remote__action_actiondetails), None]An asynchronous generator that yields updated ActionDetails objects as the action progresses.

wait()

@classmethod
def wait(
quiet: bool = False,
wait_for: WaitFor = "terminal"
) - > None

Wait for the run to complete, displaying a rich progress panel with status transitions, time elapsed, and error details in case of failure.

Parameters

NameTypeDescription
quietbool = FalseIf True, suppresses output during the wait.
wait_forWaitFor = "terminal"Specifies the state to wait for before returning. Can be 'running', 'logs-ready', or 'terminal'.

Returns

TypeDescription
NoneNone

done()

@classmethod
def done() - > bool

Check if the action is done.

Returns

TypeDescription
boolTrue if the action has reached a terminal state (succeeded, failed, aborted), False otherwise.

sync()

@classmethod
def sync() - > [Action](action.md?sid=flyte_remote__action_action)

Sync the action with the remote server. This is a placeholder for syncing the action.

Returns

TypeDescription
[Action](action.md?sid=flyte_remote__action_action)The current Action object, potentially updated with the latest state from the server.