Brian simulations can currently only run in a web browser if a server runs the code. Due to recent improvements in browser technology such as WebAssembly, browser are however capable of executing computationally complex code themselves, directly on the client machine.
The Pyodide project leverages this technology to run the Python scientific stack in the browser, and we have shown with a prototype project that this can be extended to support Brian. The specific aims of this project are to:
- create a robust Pyodide implementation of Brian2 that gets updated automatically with new releases of Brian 2
- create convenient methods to display simulation results in the browser
- investigate integrating this with the current Brian documentation and/or on a dedicated “showcase” website
- [for a 6 months project]: create a mechanism to specify model parameters that a user should be able to interactively modify when running a simulation, and expose convenient access to these controls from the HTML interface.
Planned effort: 175h or 350h (350h preferred)
Skill level: intermediate
Mentors: Marcel Stimberg @mstimberg, Dan Goodman @d.goodman
Hi @deepeshaburse. Thanks for your interest in the project. The first steps would be to familiarize yourself a bit with the pyodide project, and how our (quite crude) prototype under https://brian-team.github.io/brian2_pyodide/ works. And finally, starting to get to know Brian itself a bit (e.g. by going through the tutorial) couldn’t hurt of course
We have now posted some general recommendations for GSoC applications to our website, please have a look: Recommendations for GSoC 2022 applications | The Brian spiking neural network simulator
Regarding this project, having a close look at Creating a Pyodide package — Version 0.19.1 is essential. Ideally, try to run the described procedures for the Brian simulator, document how it went, and discuss any failures/problems you encounter.
I created *.tar.gz, and *.py3-none-any.whl files, according to the documentation in the following link Packaging Python Projects, under Uploading the distribution archives [Packaging Python Projects ], we are supposed to upload the files to “TestPyPI.” Are we allowed to upload the brian2 files to TestPyPI?
Hi @SR_Keshav I am not quite sure why you want to upload Brian packages to TestPyPI – and I don’t think you can. If you needed it, you could rename the package. Could you explain why you want to upload the package?
Hi @SR_Keshav . Ok, now I see what you mean. For the application, please note down what you tried and why and how things worked out/failed. Note that the “Creating a Pyodide package” says: “If the wheel is not on PyPI, but nevertheless you believe there is nothing preventing it (it is a Python package without C extensions)[…]” – do you think this situation applies to Brian? And if not, what would be necessary to make it apply? It also says “Then upload the wheel file somewhere (not to PyPI)” – this is not meant to refer to TestPyPI, but to some place that has an URL (e.g. a file in a git repository). It could even be on the local machine if you run a minimal web server (e.g. with
python -m http.server).
In the documentation it is said, " Check if this is the case by going to the
pypi.org/project/<package-name> URL and checking if the “Download files” tab contains a file that ends with
*py3-none-any.whl." So, when I visited Brian2 · PyPI there was no file that ends with
.py3-none-any.whl that’s why I had to create the *py3-none-any.whl.
Yes, this observation is correct. But in my comment above, I also quoted the sentence that directly followes in the documentation: "If […]you believe there is nothing preventing it (it is a Python package without C extensions)[…]”. Would you say that this is the case for Brian?
I’m not quite sure what it says, but I THINK it is saying that “if the package is a pure python package without a c extension, then the wheel is not necessary.” If what I meant was the case, then BRIAN is a package with a c extension.
Hi again. Indeed, Brian is a package with a C extension (the “spike queue” implementation). To rephrase the Pyodide documentation a bit:
- If PyPI has a pure Python wheel for the package, there is nothing you need to do, you can install it with
- If that is not the case and the package does not use any C extension, you can build the pure Python wheel yourself
- “If however the package has C extensions or its code requires patching, then continue to the next steps.”
So either one has to transform Brian into a package that does not use any C extensions (maybe that is what you have done earlier?) or one has to follow the package build instructions starting at section 2 in Creating a Pyodide package — Version 0.19.1. Hope that makes things clearer.
Yep, that made things clear for me.