# Flow Run

Experimental

The functionality here is experimental, and may change between versions without notice. Use at your own risk.

# FlowRunView

class

prefect.backend.flow_run.FlowRunView

(flow_run_id, name, flow_id, labels, parameters, context, state, states, updated_at, run_config, task_runs=None)[source]

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

Provides lazy loading of Task Runs from the flow run.

This object is designed to be an immutable view of the data stored in the Prefect backend API at the time it is created. However, each time a task run is retrieved the latest data for that task will be pulled since they are loaded lazily. Finished task runs will be cached in this object to reduce the amount of network IO.

EXPERIMENTAL: This interface is experimental and subject to change

Args:

  • flow_run_id: The uuid of the flow run
  • name: The name of the flow run
  • flow_id: The uuid of the flow this run is associated with
  • state: The state of the flow run
  • labels: The labels assigned to this flow run
  • parameters: Parameter overrides for this flow run
  • context: Context overrides for this flow run
  • updated_at: When this flow run was last updated in the backend
  • run_config: The RunConfig this flow run was configured with
  • states: A sorted list of past states the flow run has been in
  • task_runs: An iterable of task run metadata to cache in this view

methods:                                                                                                                                                       

prefect.backend.flow_run.FlowRunView.from_flow_run_id

(flow_run_id, load_static_tasks=False, _cached_task_runs=None)[source]

Get an instance of this class filled with information by querying for the given flow run id

Args:

  • flow_run_id: the flow run id to lookup
  • load_static_tasks: Pre-populate the task runs with results from flow tasks that are unmapped.
  • _cached_task_runs: Pre-populate the task runs with an existing iterable of task runs
Returns: A populated FlowRunView instance

prefect.backend.flow_run.FlowRunView.get_all_task_runs

()[source]

Get all task runs for this flow run in a single query. Finished task run data is cached so future lookups do not query the backend.

Returns: A list of TaskRunView objects

prefect.backend.flow_run.FlowRunView.get_flow_metadata

(no_cache=False)[source]

Flow metadata for the flow associated with this flow run. Retrieved from the API on first call then cached for future calls.

Args:

  • no_cache: If set, the cached FlowView will be ignored and the latest data for the flow will be pulled.
Returns: FlowView: A view of the Flow metadata for the Flow this run is from

prefect.backend.flow_run.FlowRunView.get_latest

(load_static_tasks=False)[source]

Get the a new copy of this object with the latest data from the API. Cached TaskRunView objects will be passed to the new object. Only finished tasks are cached so the cached data cannot be stale.

This will not mutate the current object.

Args:

  • load_static_tasks: Pre-populate the task runs with results from flow tasks that are unmapped. Defaults to False because it may be wasteful to query for task run data when cached tasks are already copied over from the old object.
Returns: A new instance of FlowRunView

prefect.backend.flow_run.FlowRunView.get_logs

(start_time=None, end_time=None)[source]

Get logs for this flow run from start_time to end_time.

Args:

  • start_time (optional): A time to start the log query at, useful for limiting the scope. If not provided, all logs up to updated_at are retrieved.
  • end_time (optional): A time to end the log query at. By default, this is set to self.updated_at which is the last time that the flow run was updated in the backend before this object was created.
Returns: A list of FlowRunLog objects sorted by timestamp

prefect.backend.flow_run.FlowRunView.get_task_run

(task_slug=None, task_run_id=None, map_index=None)[source]

Get information about a task run from this flow run. Lookup is available by one of the arguments. If the task information is not available locally already, we will query the database for it. If multiple arguments are provided, we will validate that they are consistent with each other.

All retrieved task runs that are finished will be cached to avoid re-querying in repeated calls

Args:

  • task_slug: A task slug string to use for the lookup
  • task_run_id: A task run uuid to use for the lookup
  • map_index: If given a slug of a mapped task, an index may be provided to get the the task run for that child task instead of the parent. This value will only be used for a consistency check if passed with a task_run_id
Returns: A cached or newly constructed TaskRunView instance

prefect.backend.flow_run.FlowRunView.get_task_run_ids

()[source]

Get all task run ids associated with this flow run. Lazily loaded at call time then cached for future calls.

Returns: A list of string task run ids



# Functions

top-level functions:                                                                                                                                                       

prefect.backend.flow_run.watch_flow_run

(flow_run_id, stream_states=True, stream_logs=True)[source]

Watch execution of a flow run displaying state changes. This function will yield FlowRunLog objects until the flow run enters a 'Finished' state.

If both stream_states and stream_logs are False then this will just block until the flow run finishes.

EXPERIMENTAL: This interface is experimental and subject to change

Args:

  • flow_run_id: The flow run to watch
  • stream_states: If set, flow run state changes will be streamed as logs
  • stream_logs: If set, logs will be streamed from the flow run
Yields: FlowRunLog: Sorted log entries

This documentation was auto-generated from commit n/a
on February 23, 2022 at 19:26 UTC