Runs

Access training runs through client.runs in the Datature Vi SDK.

A run is a single training execution. Each run belongs to a flow that defines its configuration (the dataset, model architecture, hyperparameters, and schedule). You can create runs from flows, monitor their progress, kill running runs, and retrieve model checkpoints from completed runs via the Models API.

Before You Start

Get started with the Vi SDK →


Methods

list()

List all training runs in your organization.

runs = client.runs.list()

for run in runs.items:
    print(f"Run: {run.run_id}")
    print(f"Created: {run.metadata.time_created}")
from vi.api.types import PaginationParams

runs = client.runs.list(pagination=PaginationParams(page_size=50))

for run in runs.items:
    print(f"{run.run_id}")
for page in client.runs.list():
    for run in page.items:
        status = "Unknown"
        if run.status.conditions:
            status = run.status.conditions[-1].condition.value
        print(f"{run.run_id}: {status}")
completed_runs = []

for page in client.runs.list():
    for run in page.items:
        if run.status.conditions:
            latest = run.status.conditions[-1]
            if latest.condition.value == "Succeeded":
                completed_runs.append(run)

print(f"Found {len(completed_runs)} completed runs")
all_runs = list(client.runs.list().all_items())
print(f"Total runs: {len(all_runs)}")

Parameters

Name
Type
Description
Required
Default
pagination
object
Pagination settings. Accepts PaginationParams or a dict.
Optional
PaginationParams()

Returns: PaginatedResponse[Run]


get()

Get a specific training run by ID.

run = client.runs.get("run_abc123")

print(f"Run ID: {run.run_id}")
print(f"Organization: {run.organization_id}")
run = client.runs.get("run_abc123")

if run.status.conditions:
    latest = run.status.conditions[-1]
    print(f"Status: {latest.condition.value}")
    print(f"Message: {latest.message}")
run = client.runs.get("run_abc123")

print(f"Flow Name: {run.spec.flow.name}")
print(f"Schema: {run.spec.flow.schema}")
print(f"Blocks: {len(run.spec.flow.blocks)}")

if run.spec.training_project:
    print(f"Training Dataset: {run.spec.training_project}")
run = client.runs.get("run_abc123")
run.info()  # Prints formatted run summary
import time

def wait_for_run(run_id: str, max_wait: int = 3600, check_interval: int = 30) -> str:
    """Wait for a run to complete and return the final status."""
    start_time = time.time()

    while time.time() - start_time < max_wait:
        run = client.runs.get(run_id)

        if run.status.conditions:
            latest = run.status.conditions[-1]
            status = latest.condition.value

            print(f"Status: {status}")

            if status in ["Succeeded", "Failed", "Error", "Cancelled"]:
                return status

        time.sleep(check_interval)

    raise TimeoutError("Run did not complete in time")

status = wait_for_run("run_abc123")
if status == "Succeeded":
    model = client.get_model("run_abc123")

Parameters

Name
Type
Description
Required
Default
run_id
string
Run identifier.
Required

Returns: Run


create()

Create and start a new training run from a flow configuration.

run = client.runs.create(
    flow="flow_abc123",
    training_project="project_xyz789"
)

print(f"Started run: {run.run_id}")
run = client.runs.create(
    flow={
        "name": "Quick Training",
        "schema": "v1",
        "blocks": [],
        "settings": {},
        "tolerations": {}
    }
)
run = client.runs.create(
    flow="flow_abc123",
    metadata={"experiment": "baseline", "version": "1.0"}
)

Parameters

Name
Type
Description
Required
Default
flow
string | object
Flow ID string, FlowSpec object, or dict with flow configuration.
Required
training_project
string
Training project or dataset ID.
Optional
None
metadata
object
Optional metadata attributes as key-value pairs.
Optional
None

Returns: Run


start()

Alias for create(). Creates and starts a new training run.

run = client.runs.start(
    flow="flow_abc123",
    training_project="project_xyz789"
)

print(f"Started run: {run.run_id}")

Parameters

Name
Type
Description
Required
Default
flow
string | object
Flow ID string, FlowSpec object, or dict with flow configuration.
Required
training_project
string
Training project or dataset ID.
Optional
None
metadata
object
Optional metadata attributes as key-value pairs.
Optional
None

Returns: Run


update()

Update an existing training run. Uses PATCH semantics: only provided fields are modified.

run = client.runs.update(
    run_id="run_abc123",
    metadata={"experiment": "baseline_v2", "notes": "improved accuracy"}
)
run = client.runs.update(
    run_id="run_abc123",
    spec={"training_project": "project_new123"}
)

Parameters

Name
Type
Description
Required
Default
run_id
string
Run identifier.
Required
spec
object
Partial run specification with fields to update.
Optional
None
metadata
object
Optional metadata attributes to update.
Optional
None

Returns: Run


kill()

Terminate a running training run.

run = client.runs.kill(run_id="run_abc123")
print(f"Run killed at: {run.spec.killed_at}")
run = client.runs.kill(run_id="run_abc123")

updated_run = client.runs.get(run_id="run_abc123")
if updated_run.status.conditions:
    latest = updated_run.status.conditions[-1]
    print(f"Status: {latest.condition.value}")

Parameters

Name
Type
Description
Required
Default
run_id
string
Run identifier.
Required

Returns: Run


delete()

Delete a training run permanently. This also deletes all associated model checkpoints.

deleted = client.runs.delete(run_id="run_abc123")
print(f"Deleted: {deleted.id}")
from vi import ViNotFoundError

try:
    client.runs.delete(run_id="run_abc123")
    print("Run deleted successfully")
except ViNotFoundError:
    print("Run not found or already deleted")
Permanent Operation

Deleting a run permanently removes all training data including logs, metrics, and model checkpoints. Download important models using client.models.download() before deleting a run.

Parameters

Name
Type
Description
Required
Default
run_id
string
Run identifier.
Required

Returns: DeletedResource


Condition values

The condition field in ResourceCondition reports the current run state:

Values

Name
Type
Description
Required
Default
Pending
Run is queued
Optional
Running
Run is in progress
Optional
Succeeded
Run completed successfully
Optional
Failed
Run failed
Optional
Error
Run encountered an error
Optional
Cancelled
Run was cancelled
Optional

Response types

Run

from vi.api.resources.runs.responses import Run

Properties

Name
Type
Description
Required
Default
organization_id
string
Organization ID
Optional
run_id
string
Unique identifier
Optional
spec
object
Run specification (RunSpec)
Optional
status
object
Run status (RunStatus)
Optional
metadata
object
Metadata
Optional
self_link
string
API link
Optional
etag
string
Entity tag
Optional

Methods: info() → prints a formatted run summary.


RunSpec

from vi.api.resources.runs.responses import RunSpec

Properties

Name
Type
Description
Required
Default
flow
object
Flow specification (see Flows API)
Optional
killed_at
integer
Kill timestamp, if the run was terminated
Optional
training_project
string
Training project or dataset ID
Optional

RunStatus

from vi.api.resources.runs.responses import RunStatus

Properties

Name
Type
Description
Required
Default
log
string
Log URL or path
Optional
observed_generation
integer
Observed generation number
Optional
conditions
array
Status conditions (most recent last)
Optional

Related resources

Models API

Download and inspect model checkpoints from completed runs.

Flows API

List and get the flow configurations that produce runs.

Train A Model

UI guide for starting training runs in Datature Vi.

Manage Training Runs

Cancel, delete, and organize runs in the platform.