docs/v3/api-ref/python/prefect-server-models-flows.mdx
prefect.server.models.flowsFunctions for interacting with flow ORM objects. Intended for internal use by the Prefect REST API.
create_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L21" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_flow(db: PrefectDBInterface, session: AsyncSession, flow: schemas.core.Flow) -> orm_models.Flow
Creates a new flow.
If a flow with the same name already exists, the existing flow is returned.
Args:
session: a database sessionflow: a flow modelReturns:
update_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L58" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>update_flow(db: PrefectDBInterface, session: AsyncSession, flow_id: UUID, flow: schemas.actions.FlowUpdate) -> bool
Updates a flow.
Args:
session: a database sessionflow_id: the flow id to updateflow: a flow update modelReturns:
read_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L87" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_flow(db: PrefectDBInterface, session: AsyncSession, flow_id: UUID) -> Optional[orm_models.Flow]
Reads a flow by id.
Args:
session: A database sessionflow_id: a flow idReturns:
read_flow_by_name <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L104" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_flow_by_name(db: PrefectDBInterface, session: AsyncSession, name: str) -> Optional[orm_models.Flow]
Reads a flow by name.
Args:
session: A database sessionname: a flow nameReturns:
read_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L182" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_flows(db: PrefectDBInterface, session: AsyncSession, flow_filter: Union[schemas.filters.FlowFilter, None] = None, flow_run_filter: Union[schemas.filters.FlowRunFilter, None] = None, task_run_filter: Union[schemas.filters.TaskRunFilter, None] = None, deployment_filter: Union[schemas.filters.DeploymentFilter, None] = None, work_pool_filter: Union[schemas.filters.WorkPoolFilter, None] = None, sort: schemas.sorting.FlowSort = schemas.sorting.FlowSort.NAME_ASC, offset: Union[int, None] = None, limit: Union[int, None] = None) -> Sequence[orm_models.Flow]
Read multiple flows.
Args:
session: A database sessionflow_filter: only select flows that match these filtersflow_run_filter: only select flows whose flow runs match these filterstask_run_filter: only select flows whose task runs match these filtersdeployment_filter: only select flows whose deployments match these filterswork_pool_filter: only select flows whose work pools match these filtersoffset: Query offsetlimit: Query limitReturns:
count_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L234" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>count_flows(db: PrefectDBInterface, session: AsyncSession, flow_filter: Union[schemas.filters.FlowFilter, None] = None, flow_run_filter: Union[schemas.filters.FlowRunFilter, None] = None, task_run_filter: Union[schemas.filters.TaskRunFilter, None] = None, deployment_filter: Union[schemas.filters.DeploymentFilter, None] = None, work_pool_filter: Union[schemas.filters.WorkPoolFilter, None] = None) -> int
Count flows.
Args:
session: A database sessionflow_filter: only count flows that match these filtersflow_run_filter: only count flows whose flow runs match these filterstask_run_filter: only count flows whose task runs match these filtersdeployment_filter: only count flows whose deployments match these filterswork_pool_filter: only count flows whose work pools match these filtersReturns:
delete_flow <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L275" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete_flow(db: PrefectDBInterface, session: AsyncSession, flow_id: UUID) -> bool
Delete a flow by id.
Args:
session: A database sessionflow_id: a flow idReturns:
delete_flows <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L294" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete_flows(db: PrefectDBInterface, session: AsyncSession, flow_ids: List[UUID]) -> List[UUID]
Delete multiple flows by their IDs.
This also deletes all associated deployments (hard delete).
Args:
session: A database sessionflow_ids: a list of flow ids to deleteReturns:
read_flow_labels <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/flows.py#L333" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_flow_labels(db: PrefectDBInterface, session: AsyncSession, flow_id: UUID) -> Union[schemas.core.KeyValueLabels, None]