For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
OverviewCodaControlAPI ReferenceChangelog
OverviewCodaControlAPI ReferenceChangelog
  • Coda API
  • Control API
  • Stanza API
    • stanza
    • cli
    • context
    • device
    • exceptions
      • jupyter
      • core
      • logs
      • startup
      • utils
    • models
    • pyvisa
    • registry
    • timing
    • utils
LogoLogo
On this page
  • Module Contents
  • Functions
  • API
Stanza APIjupyter

stanza.jupyter.utils

Was this page helpful?
Built with

Utilities for Jupyter notebook management.

Module Contents

Functions

NameDescription
clean_carriage_returnsRemove carriage return artifacts from logged output.
tail_logRead last N lines from log file.
format_sizeFormat bytes to human-readable string.

API

1stanza.jupyter.utils.clean_carriage_returns(text: str) -> str

Remove carriage return artifacts from logged output.

Terminal progress bars use \r to overwrite previous text. When logged to a file, this creates lines like “old_text\r new_text”. We keep only the text after the last \r on each line, which is what would be visible on a real terminal.

Parameters:

text
str

Raw text containing carriage return artifacts

Returns:

Cleaned text with only the final visible content from each line

1stanza.jupyter.utils.tail_log(
2 log_file: pathlib.Path, lines: int = 10
3) -> str

Read last N lines from log file.

Only reads last 4KB to avoid loading large files into memory. Splits on \n only to preserve \r for carriage return processing.

Parameters:

log_file
pathlib.Path

Path to the log file to read

lines
intDefaults to 10

Number of lines to return from the end of the file

Returns:

Last N lines from the log file, or empty string if file doesn’t exist

1stanza.jupyter.utils.format_size(size_bytes: int) -> str

Format bytes to human-readable string.

Parameters:

size_bytes
int

Size in bytes

Returns:

Human-readable string (e.g., “1.5 KB”, “2.3 MB”)