Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: SMC progress bars do not display correctly when called from RStudio #7409

Open
jucor opened this issue Jul 10, 2024 · 0 comments · May be fixed by #7410
Open

BUG: SMC progress bars do not display correctly when called from RStudio #7409

jucor opened this issue Jul 10, 2024 · 0 comments · May be fixed by #7410
Labels

Comments

@jucor
Copy link
Contributor

jucor commented Jul 10, 2024

Describe the issue:

When calling pyMC SMC sampling from RStudio with multiple chains, the new Rich progress bars fill the Console and the Rmarkdown output with chains lines every 0.1 seconds, eventually flooding the console and slowing down RStudio to a crawl.

This is because RStudio console output does not implement cursor movement ANSI control sequences used by Rich multi-progress bars.

See rstudio/reticulate#1632 and rstudio/rstudio#14942

Reproduceable code example:

import pymc as pm

# Run this via a Python chunk in Rstudio with reticulate

def main():

    with pm.Model() as model:
        x = pm.Normal("x", mu=0, sigma=1)
        y = pm.Normal("y", mu=x, sigma=0.001, observed=2)

    with model:
        trace = pm.sample_smc(draws=1000, chains=12, cores=1, progressbar=False)


if __name__ == "__main__":
    main()

Error message:

No error message. See the screenshot.
image

PyMC version information:

- PyMC 5.16.1, installed via Conda - Pytensor 2.23.0 (but not important) - macOS 14.5 Catalina, and also reproduced on Windows Server 2022 - rich 13.7.1 (relevant!)

Context for the issue:

This ruins every call to PyMC SMC sampler with progress bars from RStudio, and hence the use of SMC Sampler by R-heavy biostatisticians.

Turning off the progressbar would work, but then would give no visibility as to how the algorithm is progressing.

I'm submitting a PR in a minute to fix this :)

@jucor jucor added the bug label Jul 10, 2024
@jucor jucor linked a pull request Jul 10, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant