Skip to content

euroeval.logging_utils

source module euroeval.logging_utils

Utility functions related to logging.

Classes

Functions

source get_pbar(*tqdm_args, **tqdm_kwargs)tqdm

Get a progress bar for vLLM with custom hard-coded arguments.

Parameters

  • *tqdm_args Positional arguments to pass to tqdm.

  • **tqdm_kwargs Additional keyword arguments to pass to tqdm.

Returns

  • tqdm A tqdm progress bar.

source log(message: str, level: int, colour: str | None = None)None

Log a message.

Parameters

  • message : str The message to log.

  • level : int The logging level. Defaults to logging.INFO.

  • colour : str | None The colour to use for the message. If None, a default colour will be used based on the logging level.

Raises

  • ValueError If the logging level is invalid.

source log_once(message: str, level: int = logging.INFO)None

Log a message once.

This is ensured by caching the input/output pairs of this function, using the functools.cache decorator.

Parameters

  • message : str The message to log.

  • level : int The logging level. Defaults to logging.INFO.

source block_terminal_output()None

Blocks libraries from writing output to the terminal.

This filters warnings from some libraries, sets the logging level to ERROR for some libraries, disabled tokeniser progress bars when using Hugging Face tokenisers, and disables most of the logging from the transformers library.

source class no_terminal_output(disable: bool = False)

Context manager that suppresses all terminal output.

Initialise the context manager.

Parameters

  • disable : bool If True, this context manager does nothing.

source adjust_logging_level(verbose: bool, ignore_testing: bool = False)int

Adjust the logging level based on verbosity.

Parameters

  • verbose : bool Whether to output additional output.

  • ignore_testing : bool Whether to ignore the testing flag.

Returns

  • int The logging level that was set.