Table
dalva.Table
Table(
project: str,
schema: type[DalvaSchema] | None = None,
name: str | None = None,
config: InputDict | 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 object for tracking tabular data via HTTP.
log_row() and log_rows() 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.
Example
Source code in backend/src/dalva/sdk/table.py
log_row
Log a single row to the table (async — returns immediately).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Mapping[str, object]
|
Dictionary matching the table schema. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the table is already finished or has no schema. |
ValueError
|
If the row doesn't match the schema. |
Source code in backend/src/dalva/sdk/table.py
log_rows
Log multiple rows to the table (async — returns immediately).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
Iterable[Mapping[str, object]]
|
Iterable of dictionaries matching the table schema. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the table is already finished or has no schema. |
ValueError
|
If any row doesn't match the schema. |
Source code in backend/src/dalva/sdk/table.py
get_table
get_table(
stream: bool = False,
) -> (
list[dict[str, TableRowValue]]
| Generator[dict[str, TableRowValue], None, None]
)
Get all rows from the table (synchronous — drains worker first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
bool
|
If True, returns a generator yielding dicts via NDJSON streaming. |
False
|
Returns:
| Type | Description |
|---|---|
list[dict[str, TableRowValue]] | Generator[dict[str, TableRowValue], None, None]
|
List of row dicts, or a generator of row dicts if stream=True. |
Source code in backend/src/dalva/sdk/table.py
remove_table
Remove all rows from the table (synchronous — drains worker first).
Keeps table metadata and schema intact.
Source code in backend/src/dalva/sdk/table.py
flush
Source code in backend/src/dalva/sdk/table.py
finish
Finish the table and mark it as completed.
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
|
Source code in backend/src/dalva/sdk/table.py
dalva.DalvaSchema
Bases: BaseModel
Base class for Dalva table schemas.
Subclass this with fields of type: int, str, bool, float, None, list, dict. Optional[X] is supported (maps to type X, nullable).
Example
class MySchema(DalvaSchema): name: str score: float tags: list | None = None
to_column_schema
classmethod
Return column schema as [{"name": ..., "type": ...}, ...].