Dear PyMC/Fastprogress Developers,
I am writing to report an issue regarding the real-time monitoring of MCMC progress when running PyMC models in a non-interactive HPC environment (SLURM batch jobs).
Environment Details
- Installation: Conda environment (
conda-forgechannel) - Python Version: 3.14
- Library: PyMC (v.5.27.0) with
fastprogress - Execution: SLURM cluster using
python3 -uto redirectstdoutto a.outlog file.
The Problem: When executing pm.sample(progressbar=True) within a SLURM job, the progress bar often fails to provide real-time feedback. Instead of a verbose log, it renders as a single “Rich” console box (below image) that only appears in the log file once the sampling is 100% complete.
pm.sample(draws=2000, tune=1000,target_accept=0.8, cores=2, chains=2, progressbar=True, return_inferencedata=True)
Current Attempt: I have been trying to force a verbose, line-by-line text output using the following configuration at the top of my scripts:
import logging
import fastprogress
from fastprogress.fastprogress import master_bar, progress_bar
fastprogress.fastprogress.printing = True
master_bar.refresh_speed = 10
logger = logging.getLogger(“pymc”)
logger.setLevel(logging.INFO)
if not logger.handlers:
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.INFO)
formatter = logging.Formatter(‘%(asctime)s - %(name)s - %(levelname)s - %(message)s’)
handler.setFormatter(formatter)
logger.addHandler(handler)
Question: Is there a recommended or “native” way to configure PyMC/Fastprogress so that it automatically falls back to a verbose, line-by-line text progress bar when a non-TTY environment is detected? Ideally, I would like to see real-time status updates (preferably per chain) in the redirected SLURM .out file as they happen.
Thank you for your time and for the incredible work you do.
Best regards,
Jiho
