# 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.


  • 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




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


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


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

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


  • 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



Get the a new copy of this object with the latest data from the API. Cached result objects will be passed to the new object.

This will not mutate the current object.

Returns: A new instance of TaskRunView.



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



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 ffa9a6c
on February 1, 2023 at 18:44 UTC