PyBaMM icon indicating copy to clipboard operation
PyBaMM copied to clipboard

[GSoC 2025] Load model JSON files from URLs

Open medha-14 opened this issue 5 months ago • 4 comments

Description

This PR is based on #5056 and contains changes that build upon it. Once #5056 is merged, the diff for this PR will automatically update to show only the relevant changes.

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #)

Important checks:

Please confirm the following before marking the PR as ready for review:

  • No style issues: nox -s pre-commit
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctests
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

medha-14 avatar Jul 29 '25 19:07 medha-14

I've updated the entry_points.py so that models can now be loaded directly from a URL. This is how it is working at the moment.

import pybamm
url = "https://raw.githubusercontent.com/medha-14/model_json/refs/heads/main/dfn.json"
model =  pybamm.Model(url = url,battery_model=pybamm.lithium_ion.BaseModel())
sim = pybamm.Simulation(model)
sim.solve([0, 3600])
sim.plot(show_plot=False)

Please let me know if any part of this approach needs changing or improvisation.

medha-14 avatar Jul 29 '25 19:07 medha-14

@medha-14 can you change the base branch here? Would be much easier to review

Saransh-cpp avatar Jul 30 '25 13:07 Saransh-cpp

@medha-14 can you change the base branch here? Would be much easier to review

Hi @medha-14, could you please create a PR within your fork from this link? https://github.com/medha-14/PyBaMM/compare/GSoC...medha-14:PyBaMM:load_json_from_url. I see a better diff there. We could add comments on that PR until #5056 is merged. Otherwise, I think it is on the right track, modulo that we need to use platformdirs and we need tests.

agriyakhetarpal avatar Aug 04 '25 19:08 agriyakhetarpal

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 98.86%. Comparing base (a1aa02c) to head (c39d1c0).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5137      +/-   ##
===========================================
- Coverage    98.88%   98.86%   -0.03%     
===========================================
  Files          320      320              
  Lines        26949    26988      +39     
===========================================
+ Hits         26648    26681      +33     
- Misses         301      307       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 19 '25 21:08 codecov[bot]