Progress Log Manager
Proglog is a progress logging system for Python (current version 0.1.12). It enables developers to build complex libraries while offering users fine-grained control over logs, callbacks, and progress bars. It is actively maintained with releases focusing on build system improvements and documentation.
Common errors
-
ModuleNotFoundError: No module named 'proglog'
cause The `proglog` library has not been installed in the Python environment, or the environment where it's installed is not the one being used.fixInstall the library using pip: `pip install proglog` -
AttributeError: module 'proglog' has no attribute 'default_handler'
cause This error can occur if you try to access `proglog.default_handler` before `proglog.default_logger` has been initialized, or if an older version of proglog is used where this attribute might not be directly exposed or has a different name.fixEnsure `proglog.default_logger` is initialized or accessed first, which implicitly sets up the handler. If the issue persists, explicitly create and add a handler, or check the `proglog` documentation for the correct way to access or configure handlers in your specific version. -
TypeError: __init__() got an unexpected keyword argument 'display_progress_bars'
cause This error suggests that the `Logger` class (or a similar component in `proglog`) was called with an argument `display_progress_bars` that it no longer accepts or never accepted in the current version. This keyword argument was part of an earlier API or a related library.fixRemove the `display_progress_bars` argument from the `Logger` initialization. Instead, control progress bar display through other `proglog` configuration methods, such as setting the logger's level or using a specific `proglog` logger type that implicitly handles progress bars (e.g., `proglog.TqdmProgressBarLogger`). Consult the `proglog` documentation for the correct way to manage progress bar display in version 0.1.12.
Warnings
- gotcha When using `proglog.notebook()` to enable HTML progress bars, this setting applies globally to the current Python process. If different parts of an application (e.g., a script vs. an interactive session within the same process) require different progress bar behaviors (console vs. HTML), this global state can lead to unexpected display modes.
- gotcha In complex applications with nested `iter_bar` calls across multiple libraries, progress bars might interfere with each other if they implicitly use the same internal identifiers. This can lead to incorrect or confusing progress displays, especially if loop variables or names are not unique.
Install
-
pip install proglog
Imports
- default_bar_logger
from proglog import default_bar_logger
- TqdmProgressBarLogger
from proglog import TqdmProgressBarLogger
- notebook
import proglog proglog.notebook()
Quickstart
import time
from proglog import default_bar_logger, TqdmProgressBarLogger
def my_processing_function(data_items=10, logger='bar'):
"""A function that simulates work and uses proglog for progress."""
logger = default_bar_logger(logger) # Initialize logger based on input string or object
results = []
for i in logger.iter_bar(iterable=range(data_items), message="Processing data"): # Use 'iterable' for cleaner iteration
# Simulate some computational work
time.sleep(0.05)
results.append(i * 2)
return results
print("--- Running with default console progress bar ---")
my_processing_function(data_items=5)
print("\n--- Running with TQDM progress bar (explicitly passed) ---")
tqdm_logger_instance = TqdmProgressBarLogger() # Create an instance of a specific logger
my_processing_function(data_items=7, logger=tqdm_logger_instance)
print("\n--- Running with no progress bar ---")
my_processing_function(data_items=3, logger=None)
# To enable notebook specific bars, one would typically call proglog.notebook() once
# at the start of a Jupyter notebook session, before calling functions that use proglog.
# For example:
# import proglog
# proglog.notebook()
# my_processing_function(data_items=5)