Implementation:Evidentlyai Evidently SDK Artifacts
| Knowledge Sources | |
|---|---|
| Domains | SDK, Artifacts, Versioning, Storage |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Defines the SDK artifact storage system including versioned artifact models, content type abstraction, metadata tracking, and both abstract and remote API implementations for CRUD operations on artifacts and their versions.
Description
The SDK artifacts module provides the core data models and API abstractions for Evidently's artifact versioning system. Artifacts are named, versioned objects that can store different types of content such as prompts, configs, and descriptors.
ArtifactContentType: An enumeration of supported content types: Prompt, Config, Descriptor, and RunDescriptorsConfig. Each content type determines how the artifact's data is interpreted.
ArtifactContent: A generic abstract base class for content wrappers. It uses a class variable registry pattern (_CONTENT_TYPE_MAPPING) to automatically register subclasses, enabling dynamic content type resolution via _parse_any_to_content(). Content wrappers provide get_value() to extract typed values and from_value() to create wrappers from typed values.
Artifact and ArtifactMetadata: The Artifact model represents a named entity within a project, carrying an ID, project ID, name, and metadata (timestamps, author, description). ArtifactMetadata tracks creation/update times and optional author/description fields.
ArtifactVersion and ArtifactVersionMetadata: Each artifact can have multiple sequential versions (starting from 1). Each version stores an ArtifactContent instance and its ArtifactContentType. The constructor automatically wraps raw content into the appropriate ArtifactContent subclass and validates content type consistency.
RemoteArtifact: Extends Artifact with API binding capabilities. Once bound to an ArtifactAPI instance, it provides convenience methods for version management (list_versions, get_version, bump_version), deletion, and saving metadata changes.
ArtifactAPI: Abstract base class defining the full CRUD interface for artifacts and versions. Operations include list, get, create, update, delete for artifacts and their versions, plus bump_artifact_version for auto-incrementing version numbers.
RemoteArtifactAPI: Concrete implementation of ArtifactAPI that communicates with the OSS /api/artifacts REST endpoint via a RemoteWorkspace. It handles HTTP requests, response parsing, and automatic artifact binding.
Usage
This module is the foundation for all versioned content management in the Evidently SDK. It is used directly for artifact operations and indirectly through the prompt and config APIs (which may wrap artifacts via adapters). Use RemoteArtifactAPI for remote/OSS deployments or LocalArtifactAPI (from sdk.local) for local storage.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/sdk/artifacts.py
Signature
class ArtifactContentType(str, Enum):
Prompt = "prompt"
Config = "config"
Descriptor = "descriptor"
RunDescriptorsConfig = "run-descriptors-config"
class ArtifactContent(AutoAliasMixin, EvidentlyBaseModel, Generic[TArtifactValue], ABC):
data: Any
def get_value(self) -> TArtifactValue: ...
def get_type(self) -> ArtifactContentType: ...
@classmethod
@abstractmethod
def from_value(cls, value: TArtifactValue) -> "ArtifactContent": ...
class ArtifactMetadata(BaseModel):
created_at: datetime
updated_at: datetime
author: Optional[UserID] = None
description: Optional[str] = None
class Artifact(BaseModel):
id: ArtifactID
project_id: ProjectID
name: str
metadata: ArtifactMetadata
class ArtifactVersion(BaseModel):
id: ArtifactVersionID
artifact_id: ArtifactID
version: int
metadata: ArtifactVersionMetadata
content: ArtifactContent
content_type: ArtifactContentType
class RemoteArtifact(Artifact):
def bind(self, api: "ArtifactAPI") -> "RemoteArtifact": ...
def list_versions(self) -> List[ArtifactVersion]: ...
def get_version(self, version: VersionOrLatest = "latest") -> ArtifactVersion: ...
def bump_version(self, content: Any): ...
def delete(self): ...
def save(self): ...
class ArtifactAPI(ABC):
def list_artifacts(self, project_id: STR_UUID) -> List[RemoteArtifact]: ...
def get_or_create_artifact(self, project_id: STR_UUID, name: str) -> RemoteArtifact: ...
def get_artifact(self, project_id: STR_UUID, name: str) -> RemoteArtifact: ...
def create_artifact(self, project_id: STR_UUID, name: str) -> RemoteArtifact: ...
def bump_artifact_version(self, artifact_id, content: Any) -> ArtifactVersion: ...
class RemoteArtifactAPI(ArtifactAPI):
def __init__(self, workspace: "RemoteWorkspace"): ...
Import
from evidently.sdk.artifacts import Artifact, ArtifactMetadata
from evidently.sdk.artifacts import ArtifactVersion, ArtifactVersionMetadata
from evidently.sdk.artifacts import ArtifactContent, ArtifactContentType
from evidently.sdk.artifacts import RemoteArtifact, RemoteArtifactAPI
from evidently.sdk.artifacts import ArtifactAPI, VersionOrLatest
from evidently.sdk.artifacts import ArtifactID, ArtifactVersionID
I/O Contract
Artifact
| Field | Type | Description |
|---|---|---|
| id | ArtifactID (uuid.UUID) |
Unique artifact identifier |
| project_id | ProjectID (uuid.UUID) |
Parent project identifier |
| name | str |
Human-readable name |
| metadata | ArtifactMetadata |
Timestamps, author, description |
ArtifactVersion
| Field | Type | Description |
|---|---|---|
| id | ArtifactVersionID |
Unique version identifier |
| artifact_id | ArtifactID |
Parent artifact identifier |
| version | int |
Sequential version number (1, 2, 3, ...) |
| content | ArtifactContent |
Wrapped content data |
| content_type | ArtifactContentType |
Type discriminator for content |
| metadata | ArtifactVersionMetadata |
Timestamps, author, comment |
RemoteArtifactAPI Endpoints
| Method | HTTP | Endpoint |
|---|---|---|
| list_artifacts | GET | /api/artifacts?project_id={id}
|
| get_artifact | GET | /api/artifacts/by-name/{name}?project_id={id}
|
| get_artifact_by_id | GET | /api/artifacts/{artifact_id}
|
| create_artifact | POST | /api/artifacts/?project_id={id}
|
| delete_artifact | DELETE | /api/artifacts/{artifact_id}
|
| update_artifact | PUT | /api/artifacts/{artifact_id}
|
| list_versions | GET | /api/artifacts/{artifact_id}/versions
|
| get_version | GET | /api/artifacts/{artifact_id}/versions/{version}
|
| create_version | POST | /api/artifacts/{artifact_id}/versions
|
Usage Examples
from evidently.sdk.artifacts import RemoteArtifactAPI
# Create API instance
api = RemoteArtifactAPI(workspace)
# Create or get an artifact
artifact = api.get_or_create_artifact(project_id, "my-artifact")
# Create a new version
version = artifact.bump_version(content_data)
# Get latest version
latest = artifact.get_version("latest")
value = latest.content.get_value()
# List all versions
all_versions = artifact.list_versions()
# Delete the artifact
artifact.delete()