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

Added Model Entry Points #23

Merged
merged 9 commits into from
Jul 18, 2024
Merged

Conversation

santacodes
Copy link
Collaborator

@santacodes santacodes commented Jul 9, 2024

  • Implemented Model Entry Points to create Model objects within the template and initialise them through entry points.
  • Added the SPM model which can be initialised through the model entry points.
  • A wrapper method to load a model object called models("modelname/authorname") is added.
    Example -
    To load the SPM model, after installing the pybamm_cookiecutter project, it can be accessed by calling, pybamm_cookiecutter.Model("SPM"). This would return an initialised model object of the SPM model.
  • Added two basic tests for model entry points.

@valentinsulzer
Copy link
Member

Nice to see this progressing! Good to prototype this in pybamm-cookiecutter but once it works well we should move the entry point logic to PyBaMM itself to match the ParameterValues entry points, for example users should be able to do pybamm.Model("author/name")

@santacodes
Copy link
Collaborator Author

Tweaked some things to unify both the entry points for parameter_sets and models, I noticed pybamm.parameter_sets is a singleton instance for loading parameter_sets, so I made some changes to make it a doubleton instance to accommodate Model Entry Points and Parameter Sets Entry Points in the same file, as in through the same entry point, just two different instances. I tested the logic and it seems to be working, if you create a third instance through the entry point it will just return you the object of the second instance(the most recent instance that was created).
third_instance

You can load a Model by calling the pybamm_cookiecutter.Model('SPM') method, and load a parameter_set by doing pybamm_cookiecutter.parameter_sets["Chen2020"] the same way we do it in PyBaMM.

pyproject.toml Outdated Show resolved Hide resolved
src/pybamm_cookiecutter/__init__.py Show resolved Hide resolved
src/pybamm_cookiecutter/entry_point.py Show resolved Hide resolved
Copy link
Member

@agriyakhetarpal agriyakhetarpal left a comment

Choose a reason for hiding this comment

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

Slightly nitpicky, but since the API is being merged into one, could we test the model entry points and the parameter sets entry points in the same file?

src/pybamm_cookiecutter/entry_point.py Show resolved Hide resolved
src/pybamm_cookiecutter/entry_point.py Show resolved Hide resolved
src/pybamm_cookiecutter/entry_point.py Show resolved Hide resolved
@Saransh-cpp Saransh-cpp self-requested a review July 17, 2024 10:09
tests/test_entry_points.py Outdated Show resolved Hide resolved
src/pybamm_cookiecutter/entry_point.py Show resolved Hide resolved
@agriyakhetarpal
Copy link
Member

I think this looks good to me and we have two approvals too, so I propose that we merge this so that we can start moving these files to the template. It's likely we'll revisit this code many times anyway, so once we are done, we can follow @valentinsulzer's suggestion in #23 (comment) to add the same things to the PyBaMM repository

@agriyakhetarpal agriyakhetarpal merged commit 14ac3a2 into pybamm-team:main Jul 18, 2024
19 checks passed
@santacodes santacodes deleted the modelpoints branch July 18, 2024 16:16
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.

4 participants