Output

Rich terminal output utilities for the Arena CLI. Provides formatted tables, live-updating stream renderers, and structured error display.

Result Emitters

agilerl.arena.output.emit_result(result: object, is_error: bool = False, columns: list[str] | None = None, display: Callable[[Any], Any] | None = None, empty_message: str = 'No results.') → None

Emit result as JSON under --json, otherwise as a Rich table.

Parameters:
  • result (Any) – The result to emit.

  • is_error (bool) – Whether to print the result as an error.

  • columns (list[str] | None) – The columns to display in the table. If None, all columns will be displayed.

  • display (Callable[[Any], Any] | None) – Reshapes result for the table only; JSON keeps every field.

  • empty_message (str) – Printed instead of a table when result is empty.

Returns:

None

agilerl.arena.output.handle_error(exc: Exception) → None

Print an ArenaError and exit, or re-raise unknown exceptions.

Parameters:

exc (Exception) – The exception to handle.

Returns:

None

Raises:

click.exceptions.Exit – If the exception is an ArenaError.

agilerl.arena.output.emit_csv_preview(payload: bytes, *, max_rows: int) → None

Stream Renderer

class agilerl.arena.output.StreamRichRenderer(*, is_error: bool = False, error_cls: type[~agilerl.arena.exceptions.ArenaAPIError] = <class 'agilerl.arena.exceptions.ArenaAPIError'>)

Render StreamEvent objects as a live Rich table.

close() → None

Stop the live table renderer.

Returns:

None

handle_event(event: StatusEvent | CheckEvent | ErrorEvent | LogEvent) → None

Dispatch a typed stream event to the appropriate renderer.

Parameters:

event (StreamEvent) – The stream event to handle.

Returns:

None