Documentation Index Fetch the complete documentation index at: https://docs.prefect.io/llms.txt
Use this file to discover all available pages before exploring further.
prefect.server.models.artifacts
Functions
create_artifact
create_artifact(session: AsyncSession, artifact: Artifact) -> orm_models.Artifact
read_latest_artifact
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
read_artifact(db: PrefectDBInterface, session: AsyncSession, artifact_id: UUID ) -> Union[orm_models.Artifact, None ]
Reads an artifact by id.
read_artifacts
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 session
offset: Query offset
limit: Query limit
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
deployment_filter: Only select artifacts whose flow runs belong to deployments matching this filter
flow_filter: Only select artifacts whose flow runs belong to flows matching this filter
work_pool_filter: Only select artifacts whose flow runs belong to work pools matching this filter
read_latest_artifacts
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 session
offset: Query offset
limit: Query limit
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
deployment_filter: Only select artifacts whose flow runs belong to deployments matching this filter
flow_filter: Only select artifacts whose flow runs belong to flows matching this filter
work_pool_filter: Only select artifacts whose flow runs belong to work pools matching this filter
count_artifacts
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
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
update_artifact(db: PrefectDBInterface, session: AsyncSession, artifact_id: UUID , artifact: actions.ArtifactUpdate) -> bool
Updates an artifact by id.
Args:
session: A database session
artifact_id: The artifact id to update
artifact: An artifact model
Returns:
True if the update was successful, False otherwise
delete_artifact
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:
key: “foo”, id: 1, created: 2020-01-01
key: “foo”, id: 2, created: 2020-01-02
key: “foo”, id: 3, created: 2020-01-03
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 session
artifact_id: The artifact id to delete
Returns:
True if the delete was successful, False otherwise