This page serves as a permalink to the final report that provides details of Santhosh Sundaram’s project in the Google Summer of Code 2024 program.
A brief of the tasks I completed throughout the GSoC 2024 program are listed below.
entry points API
to accommodate third-party models
as well as parameter sets
.pytest
.setuptools
and hatch
, versionings like hatch-vcs
and setuptools-scm
, packaging, and for repository hosting services like GitHub and Gitlab.sphinx
for the generated project for end users.PyBaMM (Python Battery Mathematical Modeling) is an open-source Python module for the simulation of battery models. PyBaMM aims to provide a flexible, user-friendly, and high-performance platform for researchers, engineers, and developers working in the field of battery modeling and electrochemical simulations. It provides inbuilt battery models and parameter sets to visualise, simulate and analyse the overall interpretability of a battery model. It is fiscally sponsored by NumFOCUS and The Faraday Institution in the U.K
The project aims to build and publish pybamm-cookie
as a jinja
template for new PyBaMM-based projects. A copier
template is designed to simplify the setup process of the development environment for researchers and scientists interested in utilizing PyBaMM for battery modeling who may lack familiarity with managing Python environments or repositories. The project intends to enhance the accessibility and usability of PyBaMM for newbies and experienced users alike. Providing a standardized template with best practices and automation tools would lower the barrier to entry for adopting PyBaMM in battery modeling projects. This would in turn make battery modeling more accessible, efficient, and collaborative for the research community. The project also intends to implement Model entry points, allowing community contributors to create and share models of their repositories using the copier template without directly adding them upstream. This would not only let community contributors retain ownership and choose license terms but also grant flexibility to the PyBaMM team in supporting models, Including all of GitHub’s functionality and infrastructure contained within the template.
This project aims to lower the barrier to adopting PyBaMM
in battery model projects indirectly increasing the userbase of the community by automating the development environments quickly and efficiently making battery modeling more accessible, efficient, and collaborative. Additionally, the support for Model entry points allows community contributors to create and share models from their repositories without directly adding them upstream, enabling them to retain ownership, choose license terms, and leverage GitHub’s functionality. This flexibility not only empowers contributors but also allows the PyBaMM team to focus on supporting models that best align with their goals, ultimately fostering a more dynamic and inclusive research community.
pybamm-cookie
: A CLI for generating PyBaMM-based projects using copier#Due to the lack of extensive programming knowledge, especially in the area of the Python development ecosystem, researchers using PyBaMM find it difficult to set up a Python package and add their entry points to the project. That’s where my project comes in, you could set up a PyBaMM-based Python package using a single CLI command that accommodates the features of PyBaMM and you could add your third-party parameter sets and models in that package and test it! Without having to go through the overwhelming hassles of setting up a Python package for your third-party parameter sets and models. A user can define parameter sets and models that can be used for different battery chemistries and configurations and simulations. These can then be added to the generated project using pybamm-cookie
CLI and can be manually added by mapping it in pyproject.toml
under the [project.entry-points.pybamm_parameter_sets] group. This would then load the parameter set through the parameter_sets
or models
instance within the generated Python package which could be then packaged, published and accessed by a third-party user.
Parameter sets and model entry points in both these APIs had the same behaviour, while one was getting the entry points from the parameter_sets group under pyproject.toml, the other one was getting them from the models group. While it was possible to have two different APIs in the form of different files for them, I chose to unify them by initialising the entry point API with the group name in its constructor method, which gets loaded only once after the main import of the package. This reduced the complexity of code and avoided duplication of code. This would create a doubleton instance, one for parameter sets and the other for model entry points which get initialised through their group name while pybamm gets imported. This feature is planned to upstream to PyBaMM once they are done and tested in the pybamm-cookie template. While the PyBaMM project would in the future try to accommodate solvers as an entry point as well, it would be beneficial in the code base to have one single source of API to manage all the entry points.
Using github-actions
and nox
I automated the tests and separated out the sessions for testing the generated project using the CLI to ensure proper generation of the project against multiple inputs, and a session for testing the units inside the project like the entry point APIs and the user-defined tests. The API tests load the defined models and parameter sets through the entry points and ensure that they return the same object as the ones loaded without the entry points. The documentation is user-faced and basic sphinx
configuration is set up in the project inside the template. A user could use either Numpy or Google styles for documenting using doctstrings which gets rendered to HTML using sphinx. A separate nox
session for buildling the website is also present and could be locally initialised by executing nox -s docs
. The documentation builds are also tested in CI for the generated project to ensure better coverage.
miniconda
to official python bullseye
docker image.odes
dependency in the workflow.JSON
instead of CSV
to import COMSOL results.pooch
registries for data files to reduce the size of .whl
.pybamm-cookie
.pybamm-cookie
.pybamm-cookie
code base.parameter_sets
entry points to pybamm-cookie
.CONTRIBUTING.md
and README.md
.pybamm-cookie
.model
entry points to pybamm-cookie
.pybamm-cookie
.dependabot
to pybamm-cookie
.Reservoir Model
from upstream PyBaMM
to test with model entry points.git
initialisation hooks.copier
from cookiecutter
.pybamm-cookie CLI
.hatch
and setuptools
.git
initialisation bugs.JAX
solver compatibility tests.gitarchives
.pybamm-cookie
from pybamm-cookiecutter
.README.md
.PyPI
.pybamm-cookie
.--find-links
flag in uv
.I wrote a series of blogs on my journey throughout the coding period. They can be accessed on my personal blog site https://santacodes.github.io/series/gsoc/
uv
backend for nox sessions in CI for faster package resolution times - Supporting uv
by astral-sh
backend in nox would decrease the CI times as package resolutions would be faster.pybamm-cookie
usage in the PyBaMM documentation site.I would like to extend my deepest gratitude to the Google Summer of Code program, NumFOCUS, and the entire PyBaMM team for providing me with an incredible and enriching experience this summer. This journey marked my first significant contribution to the development and maintenance of open-source scientific software on such a large scale, and the lessons I’ve learned have been invaluable.
I am truly honored to have been mentored by, Saransh Chopra, Ferran Brosa Planella, Agriya Khetarpal and Arjun Verma. Their guidance and unwavering support, both in technical aspects and in fostering a positive, collaborative environment, have been immensely uplifting.
I would also like to sincerely thank Valentin Sulzer for their invaluable reviews and guidance throughout various stages of my contributions to PyBaMM and pybamm-cookie. The collective efforts of the entire PyBaMM team, their insights, and their collaborative spirit have been the driving forces behind the successes achieved during this project.
I am grateful to have completed the Google Summer of Code 2024 program and I hope to contribute to PyBaMM and its thriving codebase and community further in the future and help ameliorate the development and success of the PyBaMM ecosystem.
I am eager to incorporate the technical skills I’ve gained into my academic, personal, and professional projects in the future.
pybamm-cookie
: https://github.com/pybamm-team/pybamm-cookiepybamm-cookie
: https://pypi.org/project/pybamm-cookie/