Manage artifacts with the CLI¶
プレビュー
Workload APIはプレビュー機能で、デフォルトではオンになっています。
機能フラグ:Workload APIのエクスペリメント機能へのアクセスを有効にする
The dr artifact command group manages Workload artifacts, server-side image builds, and the local code that backs them, from your terminal. Commands are structured as follows:
dr artifact <command> [flags]
The group is split into three sub-command groups:
| Subcommand | 説明 |
|---|---|
dr artifact |
Create, list, inspect, lock, and delete artifacts on the server. |
dr artifact build |
Trigger, monitor, and inspect server-side image builds for an artifact. |
dr artifact code |
Link a local project directory to an artifact and sync code in both directions. |
Code command state directory
The code commands maintain a .wapi/ state directory at the project root that tracks which artifact, catalog, and version a directory is bound to. The model is conceptually similar to .git/—local work happens in the project root, while .wapi/ captures the remote binding and last-synced state used to detect drift on each operation.
Before you begin, enable the command group and authenticate. dr artifact and dr workload are hidden by default; a single environment variable enables both:
export DATAROBOT_CLI_FEATURE_WORKLOAD=true
dr auth login
The following is a typical code-to-Workload flow using these commands:
# Create the artifact on the server
dr artifact create --spec-file spec.json
# Link a local directory to it (use the printed ID)
dr artifact code init <artifact-id>
# Upload code and let sync fill in the codeRef
dr artifact code sync
# Build the container image server-side and wait for completion
dr artifact build create <artifact-id> --wait
# Lock the artifact for production
dr artifact lock <artifact-id>
For more information, see the detailed subcommand documentation in Subcommands.
Subcommands¶
| Subcommand | 説明 |
|---|---|
dr artifact create |
Create a Workload artifact from a JSON or YAML spec file. |
dr artifact list |
List Workload artifacts with optional filtering. |
dr artifact get |
Display details for a single Workload artifact by ID. |
dr artifact delete |
Delete a Workload artifact by ID. |
dr artifact lock |
Lock a draft artifact, making it immutable. |
dr artifact build create |
Trigger a server-side image build for an artifact. |
dr artifact build get |
Display details for a single build by ID. |
dr artifact build list |
List builds for an artifact. |
dr artifact build logs |
Print the build log for a specific build. |
dr artifact code init |
Link a project directory to an existing Workload artifact. |
dr artifact code sync |
Push local edits and pull remote changes between this directory and the linked artifact. |
dr artifact code versions |
List the catalog version history for the artifact this project directory is linked to. |
dr artifact code checkout |
Download a specific catalog version into .wapi/.checkouts/<version-id>/ for read-only inspection. |
dr artifact create¶
Create a Workload artifact from a JSON or YAML spec file.
dr artifact create --spec-file <path> [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
--spec-file <path> |
Path to a JSON or YAML spec file. 必須。 |
--output-format <text\ | json> |
Output format. Defaults to text. |
Spec file format¶
The spec file defines the Workload artifact. JSON and YAML formats are both supported. To get started, see the examples below.
{
"name": "my-agent",
"spec": {
"containerGroups": [{
"containers": [{
"imageUri": "nginx:latest",
"port": 8080,
"primary": true
}]
}]
}
}
{
"name": "my-agent",
"spec": {
"containerGroups": [{
"containers": [{
"primary": true,
"port": 8080,
"imageBuildConfig": { "dockerfile": { "source": "provided" } }
}]
}]
}
}
{
"name": "my-agent",
"description": "Optional description shown in the DataRobot UI.",
"spec": {
"containerGroups": [{
"containers": [{
"primary": true,
"port": 8080,
"imageBuildConfig": {
"dockerfile": { "source": "provided" },
"codeRef": {
"datarobot": {
"catalogId": "67890abcdef1234567890abc",
"catalogVersionId": "67890abcdef1234567890def"
}
}
}
}]
}]
}
}
Spec file validation¶
The following validation rules apply:
- Client-side:
namemust be non-empty;spec.containerGroupsmust contain at least one entry; each group'scontainersarray must contain at least one entry. - Server-side: the Workload API validates field-level shape and returns
422with a JSON-path detail on a mismatch. - Unknown fields are passed through to the server, so any field the server accepts is accepted here. The spec file is not parsed strictly.
Container lifecycles¶
The following container lifecycles are supported:
- Prebuilt image—set
imageUri(plusportandprimary) on the entry container. - Build from a provided Dockerfile—set
imageBuildConfig.dockerfile.source = "provided"to build from./Dockerfilein your synced code. - Build from a generated Dockerfile—set
imageBuildConfig.dockerfile.source = "generated"together withexecutionEnvironmentId,executionEnvironmentVersionId, andentrypointto have the server generate a Dockerfile from a base image.
Code sync fills in codeRef
dr artifact code sync fills in imageBuildConfig.codeRef automatically after the first upload, so a freshly created artifact typically does not carry a codeRef until you sync code into it.
例¶
dr artifact create --spec-file spec.json
ID: 67890abcdef1234567890abc
Name: my-agent
Status: draft
Catalog ID: —
Version ID: —
Created: 2026-05-14 10:00 UTC
Updated: 2026-05-14 10:00 UTC
dr artifact create --spec-file spec.json --output-format json
{
"id": "67890abcdef1234567890abc",
"name": "my-agent",
"status": "draft",
"catalogId": "",
"versionId": "",
"createdAt": "2026-05-14T10:00:00Z",
"updatedAt": "2026-05-14T10:00:00Z"
}
dr artifact list¶
List Workload artifacts with optional filtering.
dr artifact list [--limit <n>] [--status draft|locked] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
--limit <n> |
Maximum number of artifacts to return. Defaults to 100. Must be a positive integer. |
--status <draft\ | locked> |
Filter by status. Optional; if omitted, all statuses are returned. |
--output-format <text\ | json> |
Output format. Defaults to text. |
例¶
dr artifact list
Renders as a bordered table:
╭──────────────────────────┬───────────┬────────┬──────────────────────────┬──────────────────────────┬──────────────────────╮
│ ARTIFACT ID │ NAME │ STATUS │ CATALOG ID │ VERSION ID │ UPDATED │
├──────────────────────────┼───────────┼────────┼──────────────────────────┼──────────────────────────┼──────────────────────┤
│ 67890abcdef1234567890abc │ my-agent │ draft │ — │ — │ 2026-05-14 10:00 UTC │
│ 67890abcdef1234567890aaa │ chat-app │ locked │ 67890abcdef1234567890cat │ 67890abcdef1234567890ver │ 2026-05-13 14:32 UTC │
╰──────────────────────────┴───────────┴────────┴──────────────────────────┴──────────────────────────┴──────────────────────╯
When no artifacts match, the text output is No artifacts found. and the JSON output is {"artifacts": []}.
dr artifact list --status draft --output-format json
{
"artifacts": [
{
"id": "67890abcdef1234567890abc",
"name": "my-agent",
"status": "draft",
"catalogId": "",
"versionId": "",
"createdAt": "2026-05-14T10:00:00Z",
"updatedAt": "2026-05-14T10:00:00Z"
}
]
}
dr artifact get¶
Display details for a single Workload artifact by ID.
dr artifact get <artifact-id> [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. 必須。 |
--output-format <text\ | json> |
Output format. Defaults to text. |
例¶
dr artifact get 67890abcdef1234567890abc
ID: 67890abcdef1234567890abc
Name: my-agent
Status: draft
Catalog ID: —
Version ID: —
Created: 2026-05-14 10:00 UTC
Updated: 2026-05-14 10:00 UTC
dr artifact get 67890abcdef1234567890abc --output-format json
{
"id": "67890abcdef1234567890abc",
"name": "my-agent",
"status": "draft",
"catalogId": "",
"versionId": "",
"createdAt": "2026-05-14T10:00:00Z",
"updatedAt": "2026-05-14T10:00:00Z"
}
dr artifact delete¶
Delete a Workload artifact by ID. Two server-side rules apply: locked artifacts can never be deleted, and draft artifacts that are still referenced by a Workload cannot be deleted until the Workload is removed first.
dr artifact delete <artifact-id> [-y|--yes]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. 必須。 |
-y, --yes |
Skip the confirmation prompt. |
dr artifact lock¶
Lock a draft artifact, making it immutable and eligible for production Workloads. Locking is irreversible—to iterate further, clone the artifact or create a new one.
dr artifact lock <artifact-id> [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. 必須。 |
--output-format <text\ | json> |
Output format. Defaults to text. |
Locking is irreversible
Once locked, an artifact's name, description, and spec become immutable and the artifact can never be deleted. To iterate further, create a new draft artifact with dr artifact create.
dr artifact build create¶
Trigger a server-side image build for an artifact. The platform builds the container image from the artifact's current codeRef, pushes it to DataRobot's internal registry, and populates imageUri on the artifact. Only draft artifacts can be built.
dr artifact build create [<artifact-id>] [--wait] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. Optional when run inside a directory linked via dr artifact code init; the ID is read from .wapi/config.json. |
--wait |
Poll until the build reaches a terminal state (succeeded or failed); print the tail of the build logs on failure. |
--output-format <text\ | json> |
Output format. Defaults to text. |
前提条件¶
- The artifact must be in
draftstatus. - The artifact must have a
codeRefpointing to at least one synced catalog version. Rundr artifact code syncfirst if the artifact has no code.
例¶
# Trigger a build from a linked directory (no artifact-id needed)
dr artifact build create
# Trigger a build by artifact ID and return immediately
dr artifact build create 67890abcdef1234567890abc
# Trigger a build and wait for it to finish
dr artifact build create 67890abcdef1234567890abc --wait
dr artifact build get¶
Display details for a single build by ID.
dr artifact build get <artifact-id> <build-id> [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. 必須。 |
<build-id> |
The build ID. 必須。 |
--output-format <text\ | json> |
Output format. Defaults to text. |
dr artifact build list¶
List builds for an artifact, newest first.
dr artifact build list <artifact-id> [--limit <n>] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. 必須。 |
--limit <n> |
Maximum number of builds to return. Defaults to 100. |
--output-format <text\ | json> |
Output format. Defaults to text. |
dr artifact build logs¶
Print the build log for a specific build. When invoked with one positional argument, the artifact ID is read from .wapi/config.json in the current directory. When invoked with two, the first argument is the artifact ID.
dr artifact build logs [<artifact-id>] <build-id> [--level <level>] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
The artifact ID. Optional when run inside a linked directory; the ID is read from .wapi/config.json. |
<build-id> |
The build ID. 必須。 |
--level <level> |
Minimum log level to show: debug, info, warn, error. Defaults to info. |
--output-format <text\ | json> |
Output format. Defaults to text. |
dr artifact code init¶
Link a project directory to an existing Workload artifact. Creates a .wapi/ state directory at the project root that records which artifact, catalog, and version the directory is bound to. Required before any other code command.
dr artifact code init [<artifact-id>] [--dir <path>] [-y|--yes] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<artifact-id> |
オプションです。 If omitted in interactive mode, you'll be prompted. |
--dir <path> |
Project directory. Defaults to the current directory. |
-y, --yes |
Skip interactive prompts and use defaults. Can also be enabled via DATAROBOT_CLI_NON_INTERACTIVE=true. |
--output-format <text\ | json> |
Output format. Defaults to text. |
前提条件¶
- The artifact must already exist. Create it via
dr artifact createor in the DataRobot UI. - The artifact must be in
draftstatus. Locked artifacts are immutable.
例¶
# Interactive: prompts for the directory
dr artifact code init 67890abcdef1234567890abc
# Non-interactive: link the current directory
dr artifact code init 67890abcdef1234567890abc --yes
# Link a sibling directory
dr artifact code init 67890abcdef1234567890abc --dir ./service
dr artifact code sync¶
Push local edits and pull remote changes between this directory and the linked artifact. Computes a three-way diff against the last known state, auto-resolves conflicts (remote wins; the local version is saved as a *.LOCAL.<timestamp> copy), and applies the resulting plan in a single versioned step.
dr artifact code sync [--dir <path>] [--dry-run | --diff] [-y|--yes] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
--dir <path> |
Project directory. Defaults to the current directory. |
--dry-run |
Show the plan without writing anything. Exits before any remote write. |
--diff |
Show the plan plus per-file unified diffs. Mutually exclusive with --dry-run. Exits before any remote write. |
-y, --yes |
Auto-confirm the post-plan prompt; also skips the interactive directory prompt. |
--output-format <text\ | json> |
Output format. Defaults to text. |
前提条件¶
The directory must already be linked via dr artifact code init. Otherwise the command returns not linked: run 'dr artifact code init <artifact-id>' first.
Conflict handling¶
When the same file has diverged on both sides, sync auto-resolves by taking the remote version and writing the local copy alongside as <path>.LOCAL.<timestamp>. In interactive mode the command pauses on conflicts so you can review the plan and abort; pass --yes to skip the prompt and apply unconditionally.
JSON mode¶
In JSON mode the plan is always emitted as the first document. If neither --dry-run nor --diff is set and the plan does not require explicit confirmation, the executed result is emitted as a second JSON document.
例¶
# Preview what would change
dr artifact code sync --dry-run
# Preview with per-file diffs
dr artifact code sync --diff
# Push and pull; prompt on conflicts
dr artifact code sync
# Push and pull non-interactively
dr artifact code sync --yes
dr artifact code versions¶
List the catalog version history for the artifact this project directory is linked to.
dr artifact code versions [--dir <path>] [--limit <n>] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
--dir <path> |
Project directory. Defaults to the current directory. |
--limit <n> |
Maximum number of versions to return. Defaults to 100. Must be a positive integer. |
--output-format <text\ | json> |
Output format. Defaults to text. |
出力¶
The output marks the version that the artifact's codeRef currently points to with * and reports which version the local .wapi/ state was last synced to. This makes drift visible at a glance: a * next to a version other than the last-synced one means a sync would update local files.
前提条件¶
- The directory must be linked via
dr artifact code init. Otherwise:not linked to an artifact. Run 'dr artifact code init <id>' first. - At least one sync must have happened so the linked catalog has a version. Otherwise:
no code has been synced yet. Run 'dr artifact code sync' first.
例¶
dr artifact code versions
dr artifact code versions --limit 10
dr artifact code versions --output-format json
dr artifact code checkout¶
Download a specific catalog version into .wapi/.checkouts/<version-id>/ for read-only inspection. The working directory and .wapi/ sync state are never modified.
dr artifact code checkout [<version-id>] [--dir <path>] [--clean] [-y|--yes] [--output-format text|json]
| Argument/Flag | 説明 |
|---|---|
<version-id> |
Full version ID or any unique prefix. If omitted (and --yes is not set), you'll be prompted. |
--dir <path> |
Project directory. Defaults to the current directory. |
--clean |
Remove checkout directories instead of downloading. No positional argument removes all checkouts; a positional argument removes only the matching one. |
-y, --yes |
Skip interactive prompts. |
--output-format <text\ | json> |
Output format. Defaults to text. |
例¶
# Prompt for a version, then download
dr artifact code checkout
# Download a specific version (full ID or any unique prefix)
dr artifact code checkout abcdef12
# Download into a different project directory
dr artifact code checkout abcdef12 --dir ./service
# Remove all checkouts
dr artifact code checkout --clean
# Remove a single checkout
dr artifact code checkout abcdef12 --clean
Error handling¶
| エラー | Cause and resolution |
|---|---|
not authenticated |
Run dr auth login first; every dr artifact command requires authentication. |
invalid spec: required field 'name' is missing or empty |
The spec file's name is missing or empty. Add a non-empty string. |
invalid spec: 'spec.containerGroups' must contain at least one entry |
The spec.containerGroups array is empty. Add at least one group. |
file not found: <path> |
The --spec-file path does not exist. Check the path. |
invalid status "...": use draft or locked |
The --status value passed to artifact list is not one of the accepted values. |
artifact <id> not found |
The artifact ID does not exist. Check the ID with dr artifact list. |
artifact is locked (immutable); cannot init on a registered artifact |
Locked artifacts cannot be linked or modified. Create a new draft artifact with dr artifact create. |
not linked: run 'dr artifact code init <artifact-id>' first |
The directory has no .wapi/ state. Run dr artifact code init first. |
init aborted: project already linked |
The directory already has a .wapi/ state. Use dr artifact code sync or remove .wapi/ to re-link. |
no code has been synced yet. Run 'dr artifact code sync' first |
The linked artifact has no catalog version yet. Run sync to upload code. |
Exit codes¶
| コード | Meaning |
|---|---|
0 |
Success. |
1 |
Error (validation failed, API error, conflict, not authenticated, etc.). |
130 |
Interrupted (Ctrl+C). |