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

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

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

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

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

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

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

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

Returns: DeletedResource


Condition values

The condition field in ResourceCondition reports the current run state:

Values

Name
Type
Description
Required
Default

Response types

Run

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

Properties

Name
Type
Description
Required
Default

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


RunSpec

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

Properties

Name
Type
Description
Required
Default

RunStatus

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

Properties

Name
Type
Description
Required
Default

Related resources


Did this page help you?