# Task Run


# TaskRunView

class

prefect.backend.task_run.TaskRunView

(task_run_id, task_id, task_slug, name, state, map_index, flow_run_id)[source]

A view of Task Run data stored in the Prefect API.

Provides lazy loading of task run return values from Prefect Result locations.

This object is designed to be an immutable view of the data stored in the Prefect backend API at the time it is created.

Args:

  • task_run_id: The task run uuid
  • task_id: The uuid of the task associated with this task run
  • task_slug: The slug of the task associated with this task run
  • name: The task run name
  • state: The state of the task run
  • map_index: The map index of the task run. Is -1 if it is not a mapped subtask, otherwise it is in the index of the task run in the mapping
  • flow_run_id: The uuid of the flow run associated with this task run

methods:                                                                                                                                                       

prefect.backend.task_run.TaskRunView.from_task_run_id

(task_run_id=None)[source]

Get an instance of this class; query by task run id

Args:

  • task_run_id: The UUID identifying the task run in the backend
Returns: A populated TaskRunView instance

prefect.backend.task_run.TaskRunView.from_task_slug

(task_slug, flow_run_id, map_index=-1)[source]

Get an instance of this class; query by task slug and flow run id.

Args:

  • task_slug: The unique string identifying this task in the flow. Typically <task-name>-1.
  • flow_run_id: The UUID identifying the flow run the task run occurred in
  • map_index (optional): The index to access for mapped tasks; defaults to the parent task with a map index of -1
Returns: A populated TaskRunView instance

prefect.backend.task_run.TaskRunView.get_result

()[source]

The result of this task run loaded from the Result location. Lazily loaded on the first call then cached for repeated access. For the parent of mapped task runs, this will include the results of all children. May require credentials to be present if the result location is remote (ie S3). If your flow was run on another machine and LocalResult was used, we will fail to load the result.

See TaskRunView.iter_mapped for lazily iterating through mapped tasks instead of retrieving all of the results at once.

Returns: Any: The value your task returned

prefect.backend.task_run.TaskRunView.iter_mapped

()[source]

Iterate over the results of a mapped task, yielding a TaskRunView for each map index. This query is not performed in bulk so the results can be lazily consumed. If you want all of the task results at once, use result instead.

Yields: A TaskRunView for each mapped item



This documentation was auto-generated from commit e6bd04a
on September 7, 2022 at 21:06 UTC