Skip to content

#7519 - Move multiprocessing import for Pyodide support and enhance McBackend tests #7736

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

AtulBoyal
Copy link

@AtulBoyal AtulBoyal commented Mar 24, 2025

Description

This PR addresses Pyodide compatibility (#7519) and enhances testing:

  1. Pyodide Support (Make multiprocessing import local to support pyodide #7519):

    • Moved multiprocessing import from the top of pymc/smc/sampling.py to inside run_chains before multiprocessing.Manager(). Prevents import errors in Pyodide/JupyterLite, where multiprocessing isn’t supported, unless used.
  2. McBackend Test Improvement:

    • Updated tests/backends/test_mcbackend.py: Added debug prints (e.g., print("Expected draws:", 7)) and relaxed idata.posterior.sizes["draw"] assertion to in {7, 12} for flexibility.

Environment Notes:

  • Local: Windows 10, Python 3.10, pymc_env (scipy=1.9.3, pytest). test_smc.py (14/15 failed) and test_censored.py (4/5 failed) hit pytensor.link.c.exceptions.CompileError due to 32-bit MinGW on 64-bit system.
  • Colab: PyMC 5.21.1, test_censored.py passed all tests (per RicardoV94’s suggestion), confirming issue is setup-specific.

Related Issue

Checklist

Type of change

  • New feature / enhancement

Copy link

welcome bot commented Mar 24, 2025

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@ricardoV94
Copy link
Member

The test changes have to be reverted

@AtulBoyal AtulBoyal changed the title #7519 - Make multiprocessing import to local scope for Pyodide supportFix multiprocessing pyodide #7519 - Move multiprocessing import for Pyodide support and enhance McBackend tests Mar 25, 2025
Copy link
Member

@michaelosthege michaelosthege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks like it's an early draft?

Comment on lines +111 to +112
print(f"DEBUG: draw_idx={draw_idx}, max_index={samples[varname].shape[0]}")
print(f"DEBUG: samples shape = {samples[varname].shape}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want print statements in the code.

If anything, logging.getLogger().debug() should be used, but also not in this method which gets called thousands of times per second.

@michaelosthege michaelosthege marked this pull request as draft April 13, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make multiprocessing import local to support pyodide
3 participants