radis.misc.database_progress module

Database Progress Printer Utility

Provides unified progress output for database fetch operations across RADIS. Addresses GitHub Issue #868: Same printing when downloading from different databases.

Created on 2025-12-28

@author: tanishadahale

class DatabaseProgressPrinter(database_name: str, molecule: str, verbose: int = 1, version: str = '')[source]

Bases: object

Unified progress output for database fetch operations.

Provides consistent formatting across all database operations (HITRAN, HITEMP, ExoMol, GEISA) with configurable verbose levels.

Parameters:
  • database_name (str) – Name of the database (e.g., “HITEMP”, “ExoMol”, “HITRAN”, “GEISA”)

  • molecule (str) – Molecule being fetched (e.g., “CO2”, “H2O”)

  • verbose (int or bool) – Verbosity level: - 0 or False: Silent (no output) - 1 or True: Normal output (default) - 2+: Detailed/debug output

Example

printer = DatabaseProgressPrinter("HITEMP", "CO2", verbose=1)
printer.header("Fetching 2024 database")
printer.section("Downloading")
printer.info("3 files needed, 2 cached")
with printer.progress_bar(3, "Downloading chunks") as pbar:
    for i in range(3):
        # download work
        pbar.update(1)
printer.success("Complete: Added HITEMP-CO2-2024 to radis.json")
HEADER_WIDTH = 80[source]
complete(database_entry: str = '')[source]

Print completion message.

Parameters:

database_entry (str) – Name of database entry added to radis.json

download_progress(total_bytes: int, desc: str = 'Downloading') tqdm[source]

Return a progress bar configured for download operations.

Parameters:
  • total_bytes (int) – Total download size in bytes

  • desc (str) – Description text

Returns:

Progress bar configured for byte downloads

Return type:

tqdm

download_summary(files_needed: int, files_total: int, files_cached: int = 0)[source]

Print download summary.

Parameters:
  • files_needed (int) – Number of files that need to be downloaded

  • files_total (int) – Total number of files

  • files_cached (int) – Number of files already cached

header(action: str = '', details: str = '')[source]

Print operation header with visual separator.

Parameters:
  • action (str) – Action being performed (e.g., “Fetching”, “Downloading”)

  • details (str, optional) – Additional details for the header

info(message: str, level: int = 1, indent: int = 0)[source]

Print info message if verbose >= level.

Parameters:
  • message (str) – Message to display

  • level (int) – Minimum verbose level required to show message

  • indent (int) – Indentation level (0=none, 1=bullet, 2=sub-bullet)

lines_progress(total_lines: int | None, desc: str = 'Parsing lines') tqdm[source]

Return a progress bar configured for line parsing operations.

Parameters:
  • total_lines (int or None) – Total number of lines expected (None if unknown)

  • desc (str) – Description text

Returns:

Progress bar configured for line parsing

Return type:

tqdm

parsing_progress(total_files: int, desc: str = 'Processing files') tqdm[source]

Return a progress bar configured for file parsing operations.

Parameters:
  • total_files (int) – Total number of files to process

  • desc (str) – Description text

Returns:

Progress bar configured for file processing

Return type:

tqdm

parsing_summary(lines_loaded: int, time_elapsed: float | None = None)[source]

Print parsing summary.

Parameters:
  • lines_loaded (int) – Number of lines loaded

  • time_elapsed (float, optional) – Time taken in seconds

progress_bar(total: int, desc: str = '', unit: str = 'file', unit_scale: bool = False, unit_divisor: int = 1024, leave: bool = True, position: int = 0, disable: bool | None = None) tqdm[source]

Return a configured tqdm progress bar.

Parameters:
  • total (int) – Total number of iterations

  • desc (str) – Description text for the progress bar

  • unit (str) – Unit name (e.g., “file”, “line”, “B” for bytes)

  • unit_scale (bool) – If True, scale units automatically (useful for bytes)

  • unit_divisor (int) – Divisor for unit scaling (default 1024 for bytes)

  • leave (bool) – If True, keep progress bar after completion

  • position (int) – Position for nested progress bars

  • disable (bool or None) – If True, disable progress bar. If None, use verbose level.

Returns:

Configured progress bar instance

Return type:

tqdm

section(title: str, level: int = 1)[source]

Start a new section (Download, Parse, etc.).

Parameters:
  • title (str) – Section title (e.g., “Download”, “Parsing”, “Processing”)

  • level (int) – Minimum verbose level to show this section

success(message: str)[source]

Print success message.

Parameters:

message (str) – Success message to display

warning(message: str)[source]

Print warning message.

Parameters:

message (str) – Warning message to display

get_progress_printer(database_name: str, molecule: str, verbose: int = 1, version: str = '') DatabaseProgressPrinter[source]

Create a DatabaseProgressPrinter instance.

Parameters:
  • database_name (str) – Name of the database

  • molecule (str) – Molecule being fetched

  • verbose (int) – Verbosity level

  • version (str) – Database version

Returns:

Configured printer instance

Return type:

DatabaseProgressPrinter