Skip to main content

prefect.server.models.flows

Functions for interacting with flow ORM objects. Intended for internal use by the Prefect REST API.

Functions

emit_flow_created_event

Emit an event when a flow is created.

emit_flow_updated_event

Emit an event when a flow is updated.

emit_flow_deleted_event

Emit an event when a flow is deleted.

create_flow

Creates a new flow. If a flow with the same name already exists, the existing flow is returned. Args:
  • session: a database session
  • flow: a flow model
Returns:
  • orm_models.Flow: the newly-created or existing flow

update_flow

Updates a flow. Args:
  • session: a database session
  • flow_id: the flow id to update
  • flow: a flow update model
Returns:
  • whether or not matching rows were found to update

read_flow

Reads a flow by id. Args:
  • session: A database session
  • flow_id: a flow id
Returns:
  • orm_models.Flow: the flow

read_flow_by_name

Reads a flow by name. Args:
  • session: A database session
  • name: a flow name
Returns:
  • orm_models.Flow: the flow

read_flows

Read multiple flows. Args:
  • session: A database session
  • flow_filter: only select flows that match these filters
  • flow_run_filter: only select flows whose flow runs match these filters
  • task_run_filter: only select flows whose task runs match these filters
  • deployment_filter: only select flows whose deployments match these filters
  • work_pool_filter: only select flows whose work pools match these filters
  • offset: Query offset
  • limit: Query limit
Returns:
  • List[orm_models.Flow]: flows

count_flows

Count flows. Args:
  • session: A database session
  • flow_filter: only count flows that match these filters
  • flow_run_filter: only count flows whose flow runs match these filters
  • task_run_filter: only count flows whose task runs match these filters
  • deployment_filter: only count flows whose deployments match these filters
  • work_pool_filter: only count flows whose work pools match these filters
Returns:
  • count of flows

delete_flow

Delete a flow by id. Args:
  • session: A database session
  • flow_id: a flow id
Returns:
  • whether or not the flow was deleted

delete_flows

Delete multiple flows by their IDs. This also deletes all associated deployments (hard delete). Args:
  • session: A database session
  • flow_ids: a list of flow ids to delete
Returns:
  • List[UUID]: the IDs of the flows that were deleted

read_flow_labels