Skip to content

dalva

dalva.init

init(
    project: str,
    name: str | None = None,
    config: dict | 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

Initialize a new run.

Parameters:

Name Type Description Default
project str

Project name

required
name str | None

Optional run name (user-defined, for display purposes only)

None
config dict | None

Optional configuration dictionary

None
resume_from str | None

run_id to resume (omit to create a new run)

None
fork_from str | None

run_id to fork from (creates a copy with configs/metrics)

None
copy_tables_on_fork bool | list[int]

False (no tables), True (all tables), or list of table IDs. Only used when fork_from is set.

False
server_url str

Server URL. Defaults to http://localhost:8000

'http://localhost:8000'
outbox_dir Path | None

Directory for WAL files. Defaults to ~/.dalva/outbox/

None
http_timeout float | None

HTTP timeout in seconds. Defaults to None (no timeout).

None

Returns:

Type Description
Run

Run object

Example
import dalva
run = dalva.init(project="my-project", config={"lr": 0.001})
run.log({"loss": 0.5}, step=0)
run.finish()
Source code in backend/src/dalva/__init__.py
def init(
    project: str,
    name: str | None = None,
    config: dict | 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:
    """
    Initialize a new run.

    Args:
        project: Project name
        name: Optional run name (user-defined, for display purposes only)
        config: Optional configuration dictionary
        resume_from: run_id to resume (omit to create a new run)
        fork_from: run_id to fork from (creates a copy with configs/metrics)
        copy_tables_on_fork: False (no tables), True (all tables), or list of table IDs.
            Only used when fork_from is set.
        server_url: Server URL. Defaults to http://localhost:8000
        outbox_dir: Directory for WAL files. Defaults to ~/.dalva/outbox/
        http_timeout: HTTP timeout in seconds. Defaults to None (no timeout).

    Returns:
        Run object

    Example:
        ```python
        import dalva
        run = dalva.init(project="my-project", config={"lr": 0.001})
        run.log({"loss": 0.5}, step=0)
        run.finish()
        ```
    """
    return Run(
        project=project,
        name=name,
        config=config,
        resume_from=resume_from,
        fork_from=fork_from,
        copy_tables_on_fork=copy_tables_on_fork,
        server_url=server_url,
        outbox_dir=outbox_dir,
        http_timeout=http_timeout,
    )

dalva.table

table(
    project: str,
    schema: type[DalvaSchema] | None = None,
    name: str | None = None,
    config: dict | None = None,
    run_id: str | None = None,
    resume_from: str | None = None,
    server_url: str = "http://localhost:8000",
    outbox_dir: Path | None = None,
    http_timeout: float | None = None,
) -> Table

Initialize a new table or resume an existing one.

Parameters:

Name Type Description Default
project str

Project name

required
schema type[DalvaSchema] | None

A DalvaSchema subclass defining the table columns. Required unless resuming an existing table via resume_from.

None
name str | None

Optional table name (user-defined, for display purposes only)

None
config dict | None

Optional configuration dictionary

None
run_id str | None

Optional run_id to link this table to a run

None
resume_from str | None

table_id to resume (omit to create a new table)

None
server_url str

Server URL. Defaults to http://localhost:8000

'http://localhost:8000'
outbox_dir Path | None

Directory for WAL files. Defaults to ~/.dalva/outbox/

None
http_timeout float | None

HTTP timeout in seconds. Defaults to None (no timeout).

None

Returns:

Type Description
Table

Table object

Example
import dalva

class MySchema(dalva.DalvaSchema):
    name: str
    score: float

t = dalva.table(project="my-project", schema=MySchema)
t.log_row({"name": "test", "score": 0.5})
t.finish()
Source code in backend/src/dalva/__init__.py
def table(
    project: str,
    schema: type[DalvaSchema] | None = None,
    name: str | None = None,
    config: dict | None = None,
    run_id: str | None = None,
    resume_from: str | None = None,
    server_url: str = "http://localhost:8000",
    outbox_dir: Path | None = None,
    http_timeout: float | None = None,
) -> Table:
    """
    Initialize a new table or resume an existing one.

    Args:
        project: Project name
        schema: A DalvaSchema subclass defining the table columns. Required unless
            resuming an existing table via ``resume_from``.
        name: Optional table name (user-defined, for display purposes only)
        config: Optional configuration dictionary
        run_id: Optional run_id to link this table to a run
        resume_from: table_id to resume (omit to create a new table)
        server_url: Server URL. Defaults to http://localhost:8000
        outbox_dir: Directory for WAL files. Defaults to ~/.dalva/outbox/
        http_timeout: HTTP timeout in seconds. Defaults to None (no timeout).

    Returns:
        Table object

    Example:
        ```python
        import dalva

        class MySchema(dalva.DalvaSchema):
            name: str
            score: float

        t = dalva.table(project="my-project", schema=MySchema)
        t.log_row({"name": "test", "score": 0.5})
        t.finish()
        ```
    """
    return Table(
        project=project,
        schema=schema,
        name=name,
        config=config,
        run_id=run_id,
        resume_from=resume_from,
        server_url=server_url,
        outbox_dir=outbox_dir,
        http_timeout=http_timeout,
    )

dalva.DalvaError

DalvaError(
    message: str,
    errors: list[tuple[PendingRequest, Exception]]
    | None = None,
)

Bases: Exception

Source code in backend/src/dalva/sdk/errors.py
def __init__(
    self, message: str, errors: list[tuple[PendingRequest, Exception]] | None = None
) -> None:
    super().__init__(message)
    self.errors: list[tuple[PendingRequest, Exception]] = errors or []