yera.runtime.blocks.table

Emit normalized tabular data with optional incremental row updates.

Initial data may come from a DataFrame-like object, dictionaries, nested lists, or another supported iterable. The block normalizes columns and rows into a target-independent payload. TableStream.add_rows() emits only new rows so handlers can accumulate and update the displayed table.

Symbols

class TableStream — Stream handle for a table block that supports incremental row additions.

TableStream

Inherits: _StreamHandle

Stream handle for a table block that supports incremental row additions.

Returned by yr.table() to enable add_rows() functionality. Maintains table metadata (columns, border, block_id) and streams incremental row updates to the frontend. The frontend accumulates these rows to build the complete table state.

Methods

__init__ — Initialize a table stream.
add_rows — Add rows to the table, matching Streamlit's element.add_rows() behavior.
__enter__ — Open the table block scope.
__exit__ — Close the table block scope.

TableStream.__init__

__init__(
    block_id: str,
    columns: list[str],
    border: bool | Literal['horizontal'],
)

Initialize a table stream.

Parameters

block_id
type: str

Identity shared by table updates.

columns
type: list[str]

Ordered table column labels.

border
type: bool | Literal['horizontal']

Requested border presentation.

TableStream.add_rows

add_rows(
    data: object,
) → None

Add rows to the table, matching Streamlit's element.add_rows() behavior.

The first call to an empty table fixes the column schema from the incoming data; later calls align to it.

Supports:

  • list of lists: each inner list is a row
  • list of dicts: each dict becomes a row (keys should match existing columns)
  • pandas DataFrame: adds all rows
  • single list: treated as a single row

Parameters

data
type: object

Row-oriented values or a pandas-like data frame to append.

TableStream.__enter__

__enter__()

Open the table block scope.

Returns

This active table stream.

TableStream.__exit__

__exit__(
    exc_type: type[BaseException] | None,
    exc_value: BaseException | None,
    traceback: TracebackType,
)

Close the table block scope.

Parameters

exc_type
type: type[BaseException] | None

Type of exception leaving the context, if any.

exc_value
type: BaseException | None

Exception leaving the context, if any.

traceback
type: TracebackType

Traceback associated with the exception, if any.

Returns

False so exceptions propagate from the managed block.