1 utils.console

utils.console

Stable console types; specialized rendering helpers live in explicit leaves.

1.1 Package guide

This subpackage groups terminal behavior without turning its package marker into a formatting catalog. logging.py owns the shared verbosity/debug/logger state and the stable Console adapter. summary.py returns tensor-aware diagnostic products and optionally renders Rich trees. formatting.py builds reusable Rich panels and tables for package CLIs. cli.py runs Typer commands with consistent exit behavior.

Callers choose the narrow leaf matching their task:

from aria_nbv.utils import Console
from aria_nbv.utils.console.formatting import counts_table
from aria_nbv.utils.console.summary import summary_rows

Console and Verbosity remain available from both aria_nbv.utils and aria_nbv.utils.console. Formatting, summary, and Typer helpers are leaf-only. The console package does not define domain metrics or command policy.

1.2 Classes

Name Description
Console Console wrapper that centralises formatting and convenience helpers.
Verbosity Ordered output gates shared by every Console instance.

1.2.1 Console

utils.console.Console(**kwargs)

Console wrapper that centralises formatting and convenience helpers.

1.2.1.1 Attributes

Name Description
prefix Instance-local ::-separated source context prepended to messages.
verbosity Return the process-wide minimum level for informational output.
verbose Report whether normal informational logging is currently enabled.
is_debug Return the process-wide debug gate used by :meth:dbg.

1.2.1.2 Methods

Name Description
with_prefix Create a console instance with a prefixed context.
with_caller_prefix Create a console with prefix inferred from the caller’s module and function.
from_callsite Compatibility constructor mirroring the PRML VSLAM console API.
set_prefix Set a custom prefix for all log messages.
unset_prefix Remove this instance’s contextual prefix and return the console.
log Emit an informational message when verbosity is enabled.
log_summary Log a structured summary built from summarize.
warn Emit a warning message and include a short caller stack.
error Emit an error message and show the relevant caller stack.
plog Pretty-print an object using the best available formatter.
dbg Emit a debug message when debug mode is enabled.
dbg_summary Emit a compact tensor-aware summary when debug logging is enabled.
set_verbosity Set verbosity level (0=quiet, 1=normal, 2=verbose).
set_verbose Backward-compatible alias for set_verbosity.
set_debug Enable or disable debug logging while keeping verbose mode sensible.
set_timestamp_display Toggle timestamps for subsequent log messages.
integrate_with_logger Integrate all Console instances with PyTorch Lightning logger for WandB/TensorBoard logging.
update_global_step Update the shared global step for all console instances.
capture_sink Observe log lines in the current execution context.
1.2.1.2.1 with_prefix
utils.console.Console.with_prefix(*parts)

Create a console instance with a prefixed context.

Enables builder-style chaining.

Usage:

console = Console.with_prefix(
    self.__class__.__name__,
    <name_of_the_current_method>
    <further_parts>, # eg. stage, worker_idx...
)
1.2.1.2.2 with_caller_prefix
utils.console.Console.with_caller_prefix(*extra_parts, stack_depth=1)

Create a console with prefix inferred from the caller’s module and function.

1.2.1.2.3 from_callsite
utils.console.Console.from_callsite(*parts, stack_offset=0)

Compatibility constructor mirroring the PRML VSLAM console API.

1.2.1.2.4 set_prefix
utils.console.Console.set_prefix(*parts)

Set a custom prefix for all log messages.

Enables builder-style chaining.

1.2.1.2.5 unset_prefix
utils.console.Console.unset_prefix()

Remove this instance’s contextual prefix and return the console.

1.2.1.2.6 log
utils.console.Console.log(message)

Emit an informational message when verbosity is enabled.

1.2.1.2.7 log_summary
utils.console.Console.log_summary(label, value, *, include_stats=False)

Log a structured summary built from summarize.

1.2.1.2.8 warn
utils.console.Console.warn(message)

Emit a warning message and include a short caller stack.

1.2.1.2.9 error
utils.console.Console.error(message)

Emit an error message and show the relevant caller stack.

1.2.1.2.10 plog
utils.console.Console.plog(obj, **kwargs)

Pretty-print an object using the best available formatter.

1.2.1.2.11 dbg
utils.console.Console.dbg(message)

Emit a debug message when debug mode is enabled.

1.2.1.2.12 dbg_summary
utils.console.Console.dbg_summary(label, value, *, include_stats=False)

Emit a compact tensor-aware summary when debug logging is enabled.

1.2.1.2.13 set_verbosity
utils.console.Console.set_verbosity(level)

Set verbosity level (0=quiet, 1=normal, 2=verbose).

1.2.1.2.14 set_verbose
utils.console.Console.set_verbose(verbose)

Backward-compatible alias for set_verbosity.

1.2.1.2.15 set_debug
utils.console.Console.set_debug(is_debug)

Enable or disable debug logging while keeping verbose mode sensible.

1.2.1.2.16 set_timestamp_display
utils.console.Console.set_timestamp_display(show_timestamps)

Toggle timestamps for subsequent log messages.

1.2.1.2.17 integrate_with_logger
utils.console.Console.integrate_with_logger(logger, global_step=0)

Integrate all Console instances with PyTorch Lightning logger for WandB/TensorBoard logging.

This is a class method that sets the shared logger state for all Console instances.

1.2.1.2.17.1 Parameters
Name Type Description Default
logger Logger PyTorch Lightning logger instance (e.g., WandbLogger, TensorBoardLogger). required
global_step int Current training step for metric logging. 0
1.2.1.2.17.2 Returns
Name Type Description
type[Console] Console class for method chaining.
1.2.1.2.17.3 Example
# In your LightningModule.__init__
Console.integrate_with_logger(self.logger)

# In training_step
def training_step(self, batch, batch_idx):
    Console.update_global_step(self.global_step)
    console = Console.with_prefix("training")
    console.log("Processing batch")  # → Terminal + WandB!
1.2.1.2.18 update_global_step
utils.console.Console.update_global_step(global_step)

Update the shared global step for all console instances.

1.2.1.2.19 capture_sink
utils.console.Console.capture_sink(sink)

Observe log lines in the current execution context.

Nested and concurrent contexts remain isolated. The previous observer is restored even when the observed operation raises.

1.2.2 Verbosity

utils.console.Verbosity()

Ordered output gates shared by every Console instance.

1.2.2.1 Methods

Name Description
from_any Coerce booleans/ints/strings into a Verbosity level.
1.2.2.1.1 from_any
utils.console.Verbosity.from_any(value)

Coerce booleans/ints/strings into a Verbosity level.

Back to top