Skip to content

sift_client.resources.artifacts

CLASS DESCRIPTION
ArtifactVersionsAPIAsync

High-level API for an artifact's version history.

ArtifactsAPIAsync

High-level API for interacting with artifacts.

ATTRIBUTE DESCRIPTION
ARTIFACT_VERSION_ENTITY_TYPE

ARTIFACT_VERSION_ENTITY_TYPE module-attribute

ARTIFACT_VERSION_ENTITY_TYPE = 'artifact_versions'

ArtifactVersionsAPIAsync

ArtifactVersionsAPIAsync(sift_client: SiftClient)

Bases: _ArtifactsResourceBase

High-level API for an artifact's version history.

Every create or update writes a new version. Reachable as client.artifacts.versions.

Initialize the ArtifactVersionsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
list_

List artifact versions, newest first by default.

promote

Write a new latest version that copies an earlier version.

ATTRIBUTE DESCRIPTION
client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

list_ async

list_(
    *,
    artifact: str | Artifact | None = None,
    title: str | None = None,
    titles: list[str] | None = None,
    title_contains: str | None = None,
    artifact_ids: list[str] | list[Artifact] | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    created_by: User | str | None = None,
    metadata: dict[str, str | float | bool] | None = None,
    sources: list[Run | Asset] | None = None,
    derived_from: list[Artifact | str] | None = None,
    related_to: list[Run | Asset | Artifact] | None = None,
    file_name: str | None = None,
    created_via: ArtifactCreatedVia | None = None,
    artifact_type: ArtifactType | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[ArtifactVersion]

List artifact versions, newest first by default.

Takes the same filters as ArtifactsAPI.list_, evaluated against each version, so a filter can match an earlier version that the latest no longer matches. ArtifactVersion.is_current marks each artifact's current version.

PARAMETER DESCRIPTION
artifact

Only this Artifact or artifact ID's versions. If None, searches the versions of every artifact.

TYPE: str | Artifact | None DEFAULT: None

title

Exact title of the version.

TYPE: str | None DEFAULT: None

titles

Filter to versions with any of these titles.

TYPE: list[str] | None DEFAULT: None

title_contains

Partial title of the version.

TYPE: str | None DEFAULT: None

artifact_ids

Filter to versions of these Artifacts or artifact IDs.

TYPE: list[str] | list[Artifact] | None DEFAULT: None

created_after

Filter to versions of artifacts created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter to versions of artifacts created before this datetime.

TYPE: datetime | None DEFAULT: None

created_by

Filter to versions of artifacts created by this User or user ID.

TYPE: User | str | None DEFAULT: None

metadata

Filter to versions whose metadata has all of these key-value pairs.

TYPE: dict[str, str | float | bool] | None DEFAULT: None

sources

Filter to versions produced from any of these Runs or Assets.

TYPE: list[Run | Asset] | None DEFAULT: None

derived_from

Filter to versions derived from any of these Artifacts or artifact IDs.

TYPE: list[Artifact | str] | None DEFAULT: None

related_to

Filter to versions linked to any of these Runs, Assets, or Artifacts, by any relation.

TYPE: list[Run | Asset | Artifact] | None DEFAULT: None

file_name

Exact file name of the version.

TYPE: str | None DEFAULT: None

created_via

Filter to versions of artifacts written by this surface.

TYPE: ArtifactCreatedVia | None DEFAULT: None

artifact_type

Filter to versions of artifacts of this type.

TYPE: ArtifactType | None DEFAULT: None

include_archived

If True, include versions of archived artifacts. A named artifact lists its versions even when it is archived.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query with the ArtifactsAPI.list_ fields, evaluated against each version.

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by, over created_date, version, and title. The service default is created_date desc.

TYPE: str | None DEFAULT: None

limit

Maximum number of versions to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

page_size

Number of results to fetch per request.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[ArtifactVersion]

A list of ArtifactVersion objects that match the filter criteria.

promote async

promote(*, version: ArtifactVersion) -> Artifact

Write a new latest version that copies an earlier version.

Copies the title, summary, metadata, file, and SOURCE and DERIVED_FROM links of version. ATTACHED_TO links stay as on the latest version. Only the artifact's creator can promote, and promoting the latest version fails.

PARAMETER DESCRIPTION
version

The ArtifactVersion to promote.

TYPE: ArtifactVersion

RETURNS DESCRIPTION
Artifact

The Artifact, resolved to the version the promotion wrote.

ArtifactsAPIAsync

ArtifactsAPIAsync(sift_client: SiftClient)

Bases: _ArtifactsResourceBase

High-level API for interacting with artifacts.

An artifact is a versioned file, such as a plot or a report, that Sift stores and shows in the app. Links record where the artifact surfaces (ATTACHED_TO) and what it was produced from (SOURCE), so you can find artifacts by the runs and assets they link to.

Initialize the ArtifactsAPI.

PARAMETER DESCRIPTION
sift_client

The Sift client to use.

TYPE: SiftClient

METHOD DESCRIPTION
get

Get an artifact.

list_

List artifacts, each resolved to its latest version.

find

Find one artifact. Takes the same arguments as list_.

create

Create an artifact from a file.

update

Write a new version of an artifact.

archive

Archive an artifact. Its versions and files stay in place.

unarchive

Unarchive an artifact.

get_download_url

Get a download URL for an artifact version's file.

download

Download an artifact version's file to a local path.

read_bytes

Read an artifact version's file into memory.

ATTRIBUTE DESCRIPTION
versions

client

TYPE: SiftClient

grpc_client

TYPE: GrpcClient

rest_client

TYPE: RestClient

versions instance-attribute

versions = ArtifactVersionsAPIAsync(sift_client)

client property

client: SiftClient

grpc_client property

grpc_client: GrpcClient

rest_client property

rest_client: RestClient

get async

get(
    *,
    artifact_id: str,
    artifact_version_id: str | None = None,
) -> Artifact

Get an artifact.

PARAMETER DESCRIPTION
artifact_id

The artifact to get.

TYPE: str

artifact_version_id

Resolve to this version instead of the latest.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
Artifact

The Artifact.

list_ async

list_(
    *,
    title: str | None = None,
    titles: list[str] | None = None,
    title_contains: str | None = None,
    artifact_ids: list[str] | list[Artifact] | None = None,
    created_after: datetime | None = None,
    created_before: datetime | None = None,
    created_by: User | str | None = None,
    metadata: dict[str, str | float | bool] | None = None,
    sources: list[Run | Asset] | None = None,
    derived_from: list[Artifact | str] | None = None,
    related_to: list[Run | Asset | Artifact] | None = None,
    file_name: str | None = None,
    created_via: ArtifactCreatedVia | None = None,
    artifact_type: ArtifactType | None = None,
    include_archived: bool = False,
    filter_query: str | None = None,
    order_by: str | None = None,
    limit: int | None = None,
    page_size: int | None = None,
) -> list[Artifact]

List artifacts, each resolved to its latest version.

sources, derived_from, and related_to match the latest version's links. For other fields of the linked entity, such as a run name, use filter_query.

PARAMETER DESCRIPTION
title

Exact title of the latest version.

TYPE: str | None DEFAULT: None

titles

Filter to artifacts whose latest version has any of these titles.

TYPE: list[str] | None DEFAULT: None

title_contains

Partial title of the latest version.

TYPE: str | None DEFAULT: None

artifact_ids

Filter to these Artifacts or artifact IDs.

TYPE: list[str] | list[Artifact] | None DEFAULT: None

created_after

Filter to artifacts created after this datetime.

TYPE: datetime | None DEFAULT: None

created_before

Filter to artifacts created before this datetime.

TYPE: datetime | None DEFAULT: None

created_by

Filter to artifacts created by this User or user ID.

TYPE: User | str | None DEFAULT: None

metadata

Filter to artifacts whose latest version has all of these key-value pairs.

TYPE: dict[str, str | float | bool] | None DEFAULT: None

sources

Filter to artifacts produced from any of these Runs or Assets.

TYPE: list[Run | Asset] | None DEFAULT: None

derived_from

Filter to artifacts derived from any of these Artifacts or artifact IDs.

TYPE: list[Artifact | str] | None DEFAULT: None

related_to

Filter to artifacts linked to any of these Runs, Assets, or Artifacts, by any relation.

TYPE: list[Run | Asset | Artifact] | None DEFAULT: None

file_name

Exact file name of the latest version.

TYPE: str | None DEFAULT: None

created_via

Filter to artifacts written by this surface.

TYPE: ArtifactCreatedVia | None DEFAULT: None

artifact_type

Filter to artifacts of this type.

TYPE: ArtifactType | None DEFAULT: None

include_archived

If True, include archived artifacts in results.

TYPE: bool DEFAULT: False

filter_query

Explicit CEL query to filter artifacts. Links filter with a comprehension over runs (relation, run_id, name, description, client_key, start_time, stop_time), assets (relation, asset_id, name), canvases (relation, canvas_id, name, description), or links (relation, entity_type, entity_id).

TYPE: str | None DEFAULT: None

order_by

Field and direction to order results by, over created_date, version_created_date, archived_date, title, version, and file_type. The service default is created_date ascending.

TYPE: str | None DEFAULT: None

limit

Maximum number of artifacts to return. If None, returns all matches.

TYPE: int | None DEFAULT: None

page_size

Number of results to fetch per request.

TYPE: int | None DEFAULT: None

RETURNS DESCRIPTION
list[Artifact]

A list of Artifact objects that match the filter criteria.

Example

Artifacts produced from a run whose name contains "thermal":

client.artifacts.list_(
    filter_query='runs.exists(r, r.relation == "SOURCE" && r.name.contains("thermal"))'
)

find async

find(**kwargs) -> Artifact | None

Find one artifact. Takes the same arguments as list_.

Raises if more than one matches.

PARAMETER DESCRIPTION
**kwargs

Keyword arguments to pass to list_.

DEFAULT: {}

RETURNS DESCRIPTION
Artifact | None

The Artifact found or None.

create async

create(
    create: ArtifactCreate | dict,
    *,
    file: str | Path | bytes | BinaryIO,
    file_name: str | None = None,
) -> Artifact

Create an artifact from a file.

Creates the artifact and its first version, then uploads the file to that version.

PARAMETER DESCRIPTION
create

The artifact's title, summary, metadata, links, and surface.

TYPE: ArtifactCreate | dict

file

The file to upload: a path, bytes, or a binary file object such as io.BytesIO.

TYPE: str | Path | bytes | BinaryIO

file_name

The stored file name when file is bytes or a file object. A path upload uses the file's own name.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
Artifact

The created Artifact, resolved to version 1.

RAISES DESCRIPTION
ValueError

If file is a path that is not a regular file, or file_name is missing for bytes, not a bare name, or given with a path.

Example

Publish bytes built in memory, without writing a file first:

client.artifacts.create(
    {"title": "Peak temperatures"},
    file=json.dumps(peaks).encode(),
    file_name="peak_temperatures.json",
)

update async

update(
    artifact: str | Artifact,
    update: ArtifactUpdate | dict,
    *,
    file: str | Path | bytes | BinaryIO | None = None,
    file_name: str | None = None,
) -> Artifact

Write a new version of an artifact.

ArtifactUpdate says how each field carries forward. With file, the new version gets new bytes, and its only SOURCE and DERIVED_FROM links are the ones in update.links.

PARAMETER DESCRIPTION
artifact

The Artifact or artifact ID to update.

TYPE: str | Artifact

update

The fields to change.

TYPE: ArtifactUpdate | dict

file

New bytes for the new version: a path, bytes, or a binary file object.

TYPE: str | Path | bytes | BinaryIO | None DEFAULT: None

file_name

The stored file name when file is bytes or a file object. A path upload uses the file's own name.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
Artifact

The Artifact, resolved to the new version.

RAISES DESCRIPTION
ValueError

If the update sets no field and has no file, or file and file_name are invalid as for create.

archive async

archive(artifact: str | Artifact) -> Artifact

Archive an artifact. Its versions and files stay in place.

PARAMETER DESCRIPTION
artifact

The Artifact or artifact ID to archive.

TYPE: str | Artifact

RETURNS DESCRIPTION
Artifact

The archived Artifact.

unarchive async

unarchive(artifact: str | Artifact) -> Artifact

Unarchive an artifact.

PARAMETER DESCRIPTION
artifact

The Artifact or artifact ID to unarchive.

TYPE: str | Artifact

RETURNS DESCRIPTION
Artifact

The unarchived Artifact.

get_download_url async

get_download_url(
    *, artifact: str | Artifact | ArtifactVersion
) -> str

Get a download URL for an artifact version's file.

PARAMETER DESCRIPTION
artifact

An ArtifactVersion, an Artifact (uses its artifact_version), or an artifact ID (uses the latest version).

TYPE: str | Artifact | ArtifactVersion

RETURNS DESCRIPTION
str

The download URL.

RAISES DESCRIPTION
ValueError

If the version has no file.

download async

download(
    *,
    artifact: str | Artifact | ArtifactVersion,
    output_path: str | Path,
) -> None

Download an artifact version's file to a local path.

PARAMETER DESCRIPTION
artifact

An ArtifactVersion, an Artifact (uses its artifact_version), or an artifact ID (uses the latest version).

TYPE: str | Artifact | ArtifactVersion

output_path

The path to download the file to.

TYPE: str | Path

RAISES DESCRIPTION
ValueError

If the version has no file.

read_bytes async

read_bytes(
    *, artifact: str | Artifact | ArtifactVersion
) -> bytes

Read an artifact version's file into memory.

This holds the whole file in memory. Use download for large files.

PARAMETER DESCRIPTION
artifact

An ArtifactVersion, an Artifact (uses its artifact_version), or an artifact ID (uses the latest version).

TYPE: str | Artifact | ArtifactVersion

RETURNS DESCRIPTION
bytes

The file's bytes.

RAISES DESCRIPTION
ValueError

If the version has no file.

Example

config = json.loads(client.artifacts.read_bytes(artifact=artifact))