Run
dalva.Run
Run(
project: str,
name: str | None = None,
config: InputDict | None = None,
resume_from: str | None = None,
fork_from: str | None = None,
copy_tables_on_fork: bool | list[int] = False,
server_url: str = "http://localhost:8000",
outbox_dir: Path | None = None,
http_timeout: float | None = None,
)
Run object for tracking experiments via HTTP.
log() calls are asynchronous — they return immediately and are sent
to the server in the background. Errors from failed requests are
accumulated and reported when flush() or finish() is called.
Synchronous operations (get, remove, log_config, etc.) drain
the worker queue first to preserve ordering.
Example
Source code in backend/src/dalva/sdk/run.py
log
Log metrics to the run (async — returns immediately).
Metrics are enqueued and sent in the background. Errors are
accumulated and reported by flush() or finish().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
InputDict
|
Dictionary of metric name -> value |
required |
step
|
int | None
|
Optional step number for series values |
None
|
Example
Source code in backend/src/dalva/sdk/run.py
flush
Source code in backend/src/dalva/sdk/run.py
get
Get a specific metric from the run.
Returns a dict with key, value, and step.
If the metric does not exist, returns default (which defaults to None).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Metric name/path to retrieve |
required |
default
|
_T | None
|
Value to return if the metric does not exist. Defaults to None. |
None
|
step
|
int | None
|
Optional step number to retrieve a specific step |
None
|
Returns:
| Type | Description |
|---|---|
Metric | _T | None
|
Dict with |
Example
Source code in backend/src/dalva/sdk/run.py
remove
Remove a metric from the run (synchronous — drains queue first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metric
|
str
|
Metric name/path to remove |
required |
step
|
int | None
|
Optional step number. If omitted, removes ALL entries for this metric across all steps (scalar and series). |
None
|
Raises:
| Type | Description |
|---|---|
ConnectionError
|
On server errors (including 404 if metric not found) |
Example
Source code in backend/src/dalva/sdk/run.py
log_config
Add config key-value pairs to the run (strict insert — no overwrites).
This is synchronous and drains the worker queue first to preserve ordering.
Raises ValueError on 409 Conflict if any key already exists.
Use remove_config(key) first to overwrite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
InputDict
|
Dictionary of config key -> value. Nested dicts are flattened with '/' as separator. |
required |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
On server errors |
Source code in backend/src/dalva/sdk/run.py
get_config
Get a specific config key from the run.
Returns a dict with key and value.
If the key does not exist, returns default (which defaults to None).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Config key name to retrieve |
required |
default
|
_T | None
|
Value to return if the key does not exist. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Metric | _T | None
|
Dict with |
Example
Source code in backend/src/dalva/sdk/run.py
remove_config
Remove a config key from the run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Config key name to remove |
required |
Raises:
| Type | Description |
|---|---|
ConnectionError
|
On server errors |
Source code in backend/src/dalva/sdk/run.py
create_table
create_table(
schema: type[DalvaSchema],
name: str | None = None,
config: InputDict | None = None,
) -> Table
Create a table linked to this run.
The table is automatically associated with the same project and run. When run.finish() is called, all linked tables will be finished first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema
|
type[DalvaSchema]
|
A DalvaSchema subclass defining the table columns |
required |
name
|
str | None
|
Optional table name (user-defined, for display only) |
None
|
config
|
InputDict | None
|
Optional configuration dictionary |
None
|
Returns:
| Type | Description |
|---|---|
Table
|
Table object linked to this run |
Example
Source code in backend/src/dalva/sdk/run.py
finish
Finish the run and mark it as completed.
Drains the worker queue (blocking until all pending requests are processed or timeout seconds elapse), finishes all linked tables, then sends the finish request to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_error
|
str
|
How to handle accumulated errors from failed |
'warn'
|
timeout
|
float | None
|
Maximum seconds to wait for the worker queue to drain. Defaults to None (wait indefinitely). |
None
|
Raises:
| Type | Description |
|---|---|
DalvaError
|
If |
ConnectionError
|
If the finish request itself fails. |
Source code in backend/src/dalva/sdk/run.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |