Skip to main content

Description

Returns the path and Git revision for an artifact in a DVC project. Artifacts are managed through the DVC model registry and can have versions or be assigned to stages (like staging, production). The resulting path and revision can be used in conjunction with other dvc.api calls (like open() or read()) to access and work with the artifact.

Signature

Parameters

str
required
Name of the artifact to look up.The artifact name is defined in the model registry and typically corresponds to a model or dataset.
str
default:"None"
Version of the artifact to retrieve. Defaults to the latest version if not specified.Mutually exclusive with stage - you can specify either version or stage, not both.
str
default:"None"
Name of the model registry stage.Common stages include “staging”, “production”, “dev”, etc.Mutually exclusive with version - you can specify either version or stage, not both.
str
default:"None"
Path or URL for the DVC repository.
  • Defaults to the current project
  • Can be a local path or remote URL
  • Both HTTP and SSH protocols are supported

Returns

dict[str, str]
A dictionary containing the artifact’s Git revision and file path:
  • rev: The Git revision (commit hash) where the artifact is stored
  • path: The relative path to the artifact file within the repository

Raises

exception
Raised when the specified artifact was not found in the repository.
exception
Raised when both version and stage are specified (they are mutually exclusive).

Examples

Get Latest Version of Artifact

Get Specific Version

Get Artifact from Registry Stage

Load Artifact Using Returned Info

Open Artifact with Context Manager

Compare Staging and Production

Remote Repository Access

Handle Multiple Artifacts

Download Artifact to Local File

Error Handling

List All Versions

Validate Stage Assignment

Use Cases

Model Deployment

Retrieve production models for deployment in inference services.

Version Management

Access specific versions of models from the registry.

Stage Promotion

Get artifacts from different stages (dev, staging, production).

Model Comparison

Compare different versions or stages of the same artifact.

Model Registry Integration

Artifacts are managed through the DVC model registry. Here’s how they work:
1

Register an artifact

2

Create versions

3

Assign to stage

4

Access programmatically

Version vs Stage

Use version when you need a specific version of an artifact:

Best Practices

In deployment pipelines, use stages rather than hardcoding versions:
When you need exact reproducibility, use specific versions:
Use the returned info with other dvc.api functions:
Always handle the case where an artifact might not exist:

Common Patterns

Deployment Script

Model Version Comparison

read()

Read artifact contents

open()

Stream artifact data

get_url()

Get artifact storage URL
Learn More: See the DVC Model Registry documentation for details on managing artifacts.