Skip to main content

prefect.server.models.artifacts

Functions

emit_artifact_collection_created_event

Emit an event when an artifact collection is created.

emit_artifact_collection_updated_event

Emit an event when an artifact collection’s latest artifact changes.

emit_artifact_collection_deleted_event

Emit an event when an artifact collection is deleted.

create_artifact

read_latest_artifact

Reads the latest artifact by key. Args: session: A database session key: The artifact key Returns: Artifact: The latest artifact

read_artifact

Reads an artifact by id.

read_artifacts

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

read_latest_artifacts

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

count_artifacts

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

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

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

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:
  • key: “foo”, latest_id: 3
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