PyBaMM 25 breaks Pyodide/wasm compatibility
PyBaMM 25 no longer works with Pyodide, since solving now relies on the pybammsolvers package. PyBaMM 24 still works because it could use CasADi directly.
I was able to get PyBaMM 25 working in Pyodide by patching 3 calls to pybammsolvers in processed_variable.py.
If PyBaMM is fully moving to pybammsolvers, it would be great to:
-
Maintain wasm/Pyodide compatibility, or
-
Provide a fallback to CasADi-only solving.
A wasm build of pybammsolvers would likely fix this.
I don't think this is a high priority unless you can provide a strong reason to go through the work of a pybammsolvers WASM build
Hi @WhyNotYT, thanks for opening this issue. I didn't know that people were interested in PyBaMM working in Pyodide! Yes, PyBaMM is fully moving to pybammsolvers as the default solver. I previously experimented with a WASM build at agriyakhetarpal/pybamm-lite#1, and I was previously stuck on some build-time parallelism handling that I now think I understand how to handle. I could take this up soon and add a minimal Pyodide CI job for pybammsolvers.
I see that you have https://github.com/WhyNotYT/pybammsolvers-pyodide and https://github.com/WhyNotYT/PyBaMM-Pyodide. Please consider merging your efforts with mine; this will be beneficial for all users, as I plan to move my repository to the PyBaMM organisation once it is complete.
Hi @agriyakhetarpal, thanks for your help!
I don't have much experience in building python packages or in WebAssembly. So I couldn't make any notable progress in porting pybammsolvers to pyodide based on the pyodide docs. The https://github.com/WhyNotYT/pybammsolvers-pyodide is pretty much just an empty fork.
In https://github.com/WhyNotYT/PyBaMM-Pyodide, I removed all references to pybammsolvers and rewrote three functions (idaklu.VectorRealtypeNdArray, idaklu.observe_hermite_interp, idaklu.observe) in pure python, I can merge this but I don't think it helps in packaging pybammsolvers for pyodide or with the broader PyBaMM project.