stouputils.config module#

Global configuration module for stouputils.

This module provides the StouputilsConfig class which contains global configuration options that control the behavior of various stouputils functions. Configuration values can be set programmatically or via environment variables.

Environment Variables:

Configuration options can be overridden using environment variables with the prefix STP_ or STOUPUTILS_ followed by the configuration variable name. STP_PROCESS_TITLE_PER_WORKER=false STOUPUTILS_PROCESS_TITLE_PER_WORKER=true

Usage:
from stouputils.config import StouputilsConfig as Cfg

# Change configuration programmatically
Cfg.PROCESS_TITLE_PER_WORKER = False
ENV_PARSERS: dict[str, Callable[[str], Any]] = {'bool': <function <lambda>>, 'float': <class 'float'>, 'int': <class 'int'>}[source]#

How an environment variable is read, by the type name of the option it overrides. Any other type keeps the string.

class StouputilsConfig[source]#

Bases: object

Global configuration class for stouputils.

VERBOSE_READING_ENV: bool = False[source]#

Configuration option for verbose output when reading environment variables when stouputils is imported.

  • If true, stouputils will print out the environment variables it reads and their values. Defaults to False.

RESET: str = '\x1b[0m'[source]#
BLACK: str = '\x1b[30m'[source]#
LIGHT_GRAY: str = '\x1b[37m'[source]#
GRAY: str = '\x1b[90m'[source]#
RED: str = '\x1b[91m'[source]#
GREEN: str = '\x1b[92m'[source]#
YELLOW: str = '\x1b[93m'[source]#
BLUE: str = '\x1b[94m'[source]#
MAGENTA: str = '\x1b[95m'[source]#
CYAN: str = '\x1b[96m'[source]#
WHITE: str = '\x1b[97m'[source]#
LINE_UP: str = '\x1b[1A'[source]#
BOLD: str = '\x1b[1m'[source]#

Terminal color/style constants used throughout the package.

Used by stouputils.print and the other modules printing colored text, such as stouputils.backup.

BAR_FORMAT: str = '{l_bar}{bar}\x1b[95m| {n_fmt}/{total_fmt} [{rate_fmt}{postfix}, {elapsed}<{remaining}]\x1b[0m'[source]#

Default bar format used for TQDM progress bars.

Used by: stouputils.print and stouputils.parallel for progress bars.

FORCE_RAISE_EXCEPTION: bool = False[source]#

If true, error_log parameter will be set to LogLevels.RAISE_EXCEPTION for every next handle_error calls, useful for stouputils.all_doctests to ensure exceptions are raised during testing instead of just logged.

CPU_COUNT: int = 4[source]#

Number of CPUs to use by default for parallel operations (int). Can be overridden by setting the OMP_NUM_THREADS or MKL_NUM_THREADS environment variables.

Used by: stouputils.parallel (modules common and multi) and other concurrency helpers.

MEMORY_MEGABYTES: float = 15989.69921875[source]#

Memory this process may use, in MB, which is the container’s cap wherever it states one. 0.0 means neither the cap nor the host total could be read.

Used by: stouputils.mlflow (denominator of process/memory_usage_percentage).

PROCESS_TITLE_PER_WORKER: bool = True[source]#

Configuration option for process title in multiprocessing() function. - If true, process title is set only once per worker (reflecting worker index 0 to max_workers-1). - If false, process title is updated for each task (reflecting task index 0 to len(args)-1).

Defaults to True for easier/accurate worker identification.

Used by: stouputils.parallel.multi (see process_title_wrapper()).

CHUNK_SIZE: int = 1048576[source]#

Default chunk size for file I/O operations (bytes).

Used by: stouputils.backup and other modules performing chunked file operations.

LARGE_CHUNK_SIZE: int = 8388608[source]#

Larger chunk size for file I/O operations (bytes).

Used by: stouputils.backup and other modules needing larger I/O buffers.

COMMIT_TYPES: ClassVar[dict[str, str]] = {'api': 'API Changes', 'build': 'Build System', 'cd': 'Continuous Delivery', 'chore': 'Chores', 'ci': 'Continuous Integration', 'ci/cd': 'CI/CD', 'dep': 'Dependency Updates', 'deps': 'Dependency Updates', 'docs': 'Documentation', 'feat': 'Features', 'fix': 'Bug Fixes', 'hack': "Don't ask", 'init': 'Initial Commit', 'perf': 'Performance Improvements', 'refactor': 'Code Refactoring', 'release': 'Releases', 'revert': 'Reverts', 'security': 'Security', 'style': 'Style', 'test': 'Tests', 'uwu': 'UwU ༼ つ ◕_◕ ༽つ', 'wip': 'Work in Progress'}[source]#

Mapping of conventional commit short types to human-friendly headings used in changelogs.

Used by: stouputils.continuous_delivery.cd_utils (parsing and grouping conventional commits for changelogs).

AUTO_DOCS_REQUIREMENTS: tuple[str, ...] = ('myst_parser',)[source]#

List of requirements used by the automatic docs utilities.

Used by: stouputils.applications.automatic_docs (dependency checks for documentation generation).

SEGMENTS_UNIQUE_COLOR: tuple[float, float, float, float] = (1.0, 0.0, 0.0, 1.0)[source]#

Used by stouputils.image.numpy_segments_to_obj, which gives the first segment of an .obj its own color.

SEGMENTS_COLOR_CYCLE: tuple[tuple[float, float, float, float], ...] = ((0.0, 1.0, 0.0, 1.0), (0.0, 0.0, 1.0, 1.0), (1.0, 1.0, 0.0, 1.0), (1.0, 0.0, 1.0, 1.0), (0.0, 1.0, 1.0, 1.0))[source]#

stouputils.image.numpy_segments_to_obj (assigning default colors to segments when converting to .obj).

Type:

Used by