{"id":5082,"library":"tqdm-loggable","title":"tqdm-loggable","description":"tqdm-loggable is a petite Python package (current version 0.4.1) that provides logging-friendly TQDM progress bars. It automatically converts standard tqdm progress bars into periodic log messages when running in non-interactive or headless environments (e.g., Docker, CI/CD, background workers), ensuring that progress is visible in logs rather than being hidden by a lack of a TTY. This prevents applications from appearing frozen during long-running tqdm operations by sending regular progress reports to the configured logging backend. The project has low activity on GitHub, suggesting an infrequent release cadence.","status":"active","version":"0.4.1","language":"en","source_language":"en","source_url":"https://github.com/tradingstrategy-ai/tqdm-loggable","tags":["tqdm","logging","progress-bar","headless","monitoring","ci/cd","docker"],"install":[{"cmd":"pip install tqdm-loggable","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core functionality is built on top of tqdm.","package":"tqdm","optional":false}],"imports":[{"note":"To leverage tqdm-loggable's features, you must import its `tqdm` wrapper instead of the original `tqdm.auto.tqdm` or `tqdm.tqdm`.","wrong":"from tqdm.auto import tqdm","symbol":"tqdm","correct":"from tqdm_loggable.auto import tqdm"},{"note":"Provides utilities for configuring tqdm-loggable's logging behavior, such as setting the log level and rate.","symbol":"tqdm_logging","correct":"from tqdm_loggable.tqdm_logging import tqdm_logging"}],"quickstart":{"code":"import datetime\nimport logging\nimport time\nimport os\nfrom tqdm_loggable.auto import tqdm\nfrom tqdm_loggable.tqdm_logging import tqdm_logging\n\n# Configure basic logging\nlogger = logging.getLogger()\nlogger.setLevel(logging.INFO)\nformatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')\nhandler = logging.StreamHandler()\nhandler.setFormatter(formatter)\nlogger.addHandler(handler)\n\n# Optional: Set tqdm-loggable's log level and update rate\ntqdm_logging.set_level(logging.INFO)\ntqdm_logging.set_log_rate(datetime.timedelta(seconds=2))\n\n# You can force logging mode by setting an environment variable:\n# os.environ['TQDM_LOGGABLE_FORCE'] = 'logging' # Forcing log output\n# os.environ['TQDM_LOGGABLE_FORCE'] = 'stdout'  # Forcing console bar\n# os.environ['TQDM_LOGGABLE_FORCE'] = 'auto'   # Restore auto-detection\n\nprint(\"Starting a simulated task...\")\nfor i in tqdm(range(20), desc=\"Processing items\", unit=\"item\"):\n    time.sleep(0.5)\n    if i == 5:\n        logger.info(\"Mid-task progress report\")\n\nprint(\"Task completed.\")\n","lang":"python","description":"This quickstart demonstrates how to integrate `tqdm-loggable`. It configures standard Python logging, then uses `tqdm_loggable.auto.tqdm` to wrap an iterable. In an interactive terminal, this will show a normal progress bar. When run in a headless environment, or if `TQDM_LOGGABLE_FORCE=logging` is set, it will emit periodic log messages instead of an interactive bar, like 'Progress on: Processing items 10/20 rate:X it/s remaining:Y elapsed:Z'. The `set_log_rate` controls how frequently these log messages appear."},"warnings":[{"fix":"Ensure you understand the distinct use cases. Use `tqdm-loggable` for headless logging; use `tqdm.contrib.logging` within interactive sessions to manage log output alongside progress bars.","message":"Do not confuse `tqdm-loggable` with `tqdm.contrib.logging`. They address different problems: `tqdm-loggable` converts progress bars to log messages in headless environments, while `tqdm.contrib.logging` redirects console log output to `tqdm.write()` to prevent interference with interactive bars.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If unexpected behavior occurs, check or explicitly set the `TQDM_LOGGABLE_FORCE` environment variable to control the output mode.","message":"tqdm-loggable automatically detects interactive vs. non-interactive sessions to determine whether to show an interactive bar or log messages. This auto-detection can be overridden by setting the `TQDM_LOGGABLE_FORCE` environment variable to `stdout` (force interactive), `logging` (force log output), or `auto` (restore default behavior).","severity":"gotcha","affected_versions":"All versions"},{"fix":"For feature requests or pull requests, the maintainers suggest poking them on Discord first to ensure visibility.","message":"The GitHub repository for `tqdm-loggable` indicates low activity. This means new feature requests or bug reports might experience slower response times.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware of this behavioral shift. The `set_log_rate` function in `tqdm_loggable.tqdm_logging` can be used to control the frequency of log updates to suit your monitoring needs.","message":"When migrating from standard `tqdm` to `tqdm-loggable` in a headless environment, the expected output will change from no visible progress (or broken output) to periodic log messages. While this is the library's intended function, it is a significant behavioral change from `tqdm`'s default in non-interactive contexts.","severity":"breaking","affected_versions":"All versions where `tqdm` is used in headless mode"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}