docs/v3/api-ref/python/prefect-server-models-artifacts.mdx
prefect.server.models.artifactscreate_artifact <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L99" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>create_artifact(session: AsyncSession, artifact: Artifact) -> orm_models.Artifact
read_latest_artifact <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_latest_artifact(db: PrefectDBInterface, session: AsyncSession, key: str) -> Union[orm_models.ArtifactCollection, None]
Reads the latest artifact by key. Args: session: A database session key: The artifact key Returns: Artifact: The latest artifact
read_artifact <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L141" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_artifact(db: PrefectDBInterface, session: AsyncSession, artifact_id: UUID) -> Union[orm_models.Artifact, None]
Reads an artifact by id.
read_artifacts <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L251" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_artifacts(db: PrefectDBInterface, session: AsyncSession, offset: Optional[int] = None, limit: Optional[int] = None, artifact_filter: Optional[filters.ArtifactFilter] = None, flow_run_filter: Optional[filters.FlowRunFilter] = None, task_run_filter: Optional[filters.TaskRunFilter] = None, deployment_filter: Optional[filters.DeploymentFilter] = None, flow_filter: Optional[filters.FlowFilter] = None, sort: sorting.ArtifactSort = sorting.ArtifactSort.ID_DESC) -> Sequence[orm_models.Artifact]
Reads artifacts.
Args:
session: A database sessionoffset: Query offsetlimit: Query limitartifact_filter: Only select artifacts matching this filterflow_run_filter: Only select artifacts whose flow runs matching this filtertask_run_filter: Only select artifacts whose task runs matching this filterdeployment_filter: Only select artifacts whose flow runs belong to deployments matching this filterflow_filter: Only select artifacts whose flow runs belong to flows matching this filterwork_pool_filter: Only select artifacts whose flow runs belong to work pools matching this filterread_latest_artifacts <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L299" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_latest_artifacts(db: PrefectDBInterface, session: AsyncSession, offset: Optional[int] = None, limit: Optional[int] = None, artifact_filter: Optional[filters.ArtifactCollectionFilter] = None, flow_run_filter: Optional[filters.FlowRunFilter] = None, task_run_filter: Optional[filters.TaskRunFilter] = None, deployment_filter: Optional[filters.DeploymentFilter] = None, flow_filter: Optional[filters.FlowFilter] = None, sort: sorting.ArtifactCollectionSort = sorting.ArtifactCollectionSort.ID_DESC) -> Sequence[orm_models.ArtifactCollection]
Reads artifacts.
Args:
session: A database sessionoffset: Query offsetlimit: Query limitartifact_filter: Only select artifacts matching this filterflow_run_filter: Only select artifacts whose flow runs matching this filtertask_run_filter: Only select artifacts whose task runs matching this filterdeployment_filter: Only select artifacts whose flow runs belong to deployments matching this filterflow_filter: Only select artifacts whose flow runs belong to flows matching this filterwork_pool_filter: Only select artifacts whose flow runs belong to work pools matching this filtercount_artifacts <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L346" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>count_artifacts(db: PrefectDBInterface, session: AsyncSession, artifact_filter: Optional[filters.ArtifactFilter] = None, flow_run_filter: Optional[filters.FlowRunFilter] = None, task_run_filter: Optional[filters.TaskRunFilter] = None, deployment_filter: Optional[filters.DeploymentFilter] = None, flow_filter: Optional[filters.FlowFilter] = None) -> int
Counts artifacts. Args: session: A database session artifact_filter: Only select artifacts matching this filter flow_run_filter: Only select artifacts whose flow runs matching this filter task_run_filter: Only select artifacts whose task runs matching this filter
count_latest_artifacts <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L380" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>count_latest_artifacts(db: PrefectDBInterface, session: AsyncSession, artifact_filter: Optional[filters.ArtifactCollectionFilter] = None, flow_run_filter: Optional[filters.FlowRunFilter] = None, task_run_filter: Optional[filters.TaskRunFilter] = None, deployment_filter: Optional[filters.DeploymentFilter] = None, flow_filter: Optional[filters.FlowFilter] = None) -> int
Counts artifacts. Args: session: A database session artifact_filter: Only select artifacts matching this filter flow_run_filter: Only select artifacts whose flow runs matching this filter task_run_filter: Only select artifacts whose task runs matching this filter
update_artifact <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L414" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>update_artifact(db: PrefectDBInterface, session: AsyncSession, artifact_id: UUID, artifact: actions.ArtifactUpdate) -> bool
Updates an artifact by id.
Args:
session: A database sessionartifact_id: The artifact id to updateartifact: An artifact modelReturns:
delete_artifact <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/models/artifacts.py#L453" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>delete_artifact(db: PrefectDBInterface, session: AsyncSession, artifact_id: UUID) -> bool
Deletes an artifact by id.
The ArtifactCollection table is used to track the latest version of an artifact by key. If we are deleting the latest version of an artifact from the Artifact table, we need to first update the latest version referenced in ArtifactCollection so that it points to the next latest version of the artifact.
Example: If we have the following artifacts in Artifact:
the ArtifactCollection table has the following entry:
If we delete the artifact with id 3, we need to update the latest version of the artifact with key "foo" to be the artifact with id 2.
Args:
session: A database sessionartifact_id: The artifact id to deleteReturns: