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 |
|
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:
|
| 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:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
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:
|
title
|
Exact title of the version.
TYPE:
|
titles
|
Filter to versions with any of these titles.
TYPE:
|
title_contains
|
Partial title of the version.
TYPE:
|
artifact_ids
|
Filter to versions of these Artifacts or artifact IDs.
TYPE:
|
created_after
|
Filter to versions of artifacts created after this datetime.
TYPE:
|
created_before
|
Filter to versions of artifacts created before this datetime.
TYPE:
|
created_by
|
Filter to versions of artifacts created by this User or user ID.
TYPE:
|
metadata
|
Filter to versions whose metadata has all of these key-value pairs.
TYPE:
|
sources
|
Filter to versions produced from any of these Runs or Assets. |
derived_from
|
Filter to versions derived from any of these Artifacts or artifact IDs.
TYPE:
|
related_to
|
Filter to versions linked to any of these Runs, Assets, or Artifacts, by any relation. |
file_name
|
Exact file name of the version.
TYPE:
|
created_via
|
Filter to versions of artifacts written by this surface.
TYPE:
|
artifact_type
|
Filter to versions of artifacts of this type.
TYPE:
|
include_archived
|
If True, include versions of archived artifacts. A named
TYPE:
|
filter_query
|
Explicit CEL query with the
TYPE:
|
order_by
|
Field and direction to order results by, over
TYPE:
|
limit
|
Maximum number of versions to return. If None, returns all matches.
TYPE:
|
page_size
|
Number of results to fetch per request.
TYPE:
|
| 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:
|
| 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:
|
| METHOD | DESCRIPTION |
|---|---|
get |
Get an artifact. |
list_ |
List artifacts, each resolved to its latest version. |
find |
Find one artifact. Takes the same arguments as |
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:
|
grpc_client |
TYPE:
|
rest_client |
TYPE:
|
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:
|
artifact_version_id
|
Resolve to this version instead of the latest.
TYPE:
|
| 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:
|
titles
|
Filter to artifacts whose latest version has any of these titles.
TYPE:
|
title_contains
|
Partial title of the latest version.
TYPE:
|
artifact_ids
|
Filter to these Artifacts or artifact IDs.
TYPE:
|
created_after
|
Filter to artifacts created after this datetime.
TYPE:
|
created_before
|
Filter to artifacts created before this datetime.
TYPE:
|
created_by
|
Filter to artifacts created by this User or user ID.
TYPE:
|
metadata
|
Filter to artifacts whose latest version has all of these key-value pairs.
TYPE:
|
sources
|
Filter to artifacts produced from any of these Runs or Assets. |
derived_from
|
Filter to artifacts derived from any of these Artifacts or artifact IDs.
TYPE:
|
related_to
|
Filter to artifacts linked to any of these Runs, Assets, or Artifacts, by any relation. |
file_name
|
Exact file name of the latest version.
TYPE:
|
created_via
|
Filter to artifacts written by this surface.
TYPE:
|
artifact_type
|
Filter to artifacts of this type.
TYPE:
|
include_archived
|
If True, include archived artifacts in results.
TYPE:
|
filter_query
|
Explicit CEL query to filter artifacts. Links filter with a
comprehension over
TYPE:
|
order_by
|
Field and direction to order results by, over
TYPE:
|
limit
|
Maximum number of artifacts to return. If None, returns all matches.
TYPE:
|
page_size
|
Number of results to fetch per request.
TYPE:
|
| 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
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:
|
file
|
The file to upload: a path, bytes, or a binary file object such as
TYPE:
|
file_name
|
The stored file name when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Artifact
|
The created Artifact, resolved to version 1. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
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:
|
update
|
The fields to change.
TYPE:
|
file
|
New bytes for the new version: a path, bytes, or a binary file object.
TYPE:
|
file_name
|
The stored file name when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Artifact
|
The Artifact, resolved to the new version. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the update sets no field and has no |
archive
async
¶
unarchive
async
¶
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
TYPE:
|
| 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
TYPE:
|
output_path
|
The path to download the file to.
TYPE:
|
| 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
TYPE:
|
| 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))