Skip to content

test: verify datastore is omitted from checkpoint hparams (#148) - #232

Merged
sadamov merged 1 commit into
mllam:mainfrom
Jayant-kernel:fix/148-datastore-checkpoint-regression
Jun 6, 2026
Merged

test: verify datastore is omitted from checkpoint hparams (#148)#232
sadamov merged 1 commit into
mllam:mainfrom
Jayant-kernel:fix/148-datastore-checkpoint-regression

Conversation

@Jayant-kernel

@Jayant-kernel Jayant-kernel commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

This PR adds a minimal regression test to verify that the datastore object is correctly excluded from the pickled PyTorch Lightning checkpoint hyperparameters.

The save_hyperparameters(ignore=["datastore"]) call was already previously implemented inside ARModel and successfully propagates to all model subclasses via super().__init__(). This test simply locks in that behavior by saving a checkpoint to disk and asserting the dictionary keys, ensuring no future refactors accidentally bypass it.

  • Instantiates a minimal dummy graph and GraphLAM model.
  • Mimics Lightning's standard trainer.save_checkpoint.
  • Asserts that "datastore" is absent from the saved checkpoint["hyper_parameters"] dictionary.

Issue Link

Closes #148

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation (Addition or improvements to documentation)

Checklist before requesting a review

  • My branch is up-to-date with the target branch
  • I have performed a self-review of my code
  • For any new/modified functions/classes I have added docstrings that clearly describe its purpose, expected inputs and returned values
  • I have placed in-line comments to clarify the intent of any hard-to-understand passages of my code
  • I have updated the README to cover introduced code changes (N/A)
  • I have added tests that prove my fix is effective or that my feature works
  • I have given the PR a name that clearly describes the change, written in imperative form.
  • I have requested a reviewer and an assignee

Checklist for reviewers

Each PR comes with its own improvements and flaws. The reviewer should check the following:

  • the code is readable
  • the code is well tested
  • the code is documented (including return types and parameters)
  • the code is easy to maintain

Author checklist after completed review

  • I have added a line to the CHANGELOG describing this change, in a section
    reflecting type of change (add section where missing):
    • added: when you have added new functionality
    • changed: when default behaviour of the code has been changed
    • fixes: when your contribution fixes a bug
    • maintenance: when your contribution is relates to repo maintenance, e.g. CI/CD or documentation

Checklist for assignee

  • PR is up to date with the base branch
  • the tests pass
  • (if the PR is not just maintenance/bugfix) the PR is assigned to the next milestone. If it is not, propose it for a future milestone.
  • author has added an entry to the changelog (and designated the change as added, changed, fixed or maintenance)

@Jayant-kernel

Copy link
Copy Markdown
Contributor Author

@joeloskarsson
Please review the change when you are free

@leifdenby

Copy link
Copy Markdown
Member

@Jayant-kernel would you be able to use the default PR template instead please? I helps with the review process to make sure we have checked everything :) Once you've done that one of us will give your work a review.

Thank you for you contribution!

@Jayant-kernel

Copy link
Copy Markdown
Contributor Author

@leifdenby
I have changed the template as required.

thanks

@joeloskarsson
joeloskarsson self-requested a review February 28, 2026 20:15
@sadamov sadamov added enhancement New feature or request good first issue Good for newcomers labels Mar 1, 2026
@Jayant-kernel

Copy link
Copy Markdown
Contributor Author

@joeloskarsson @leifdenby @sadamov
I pushed a small follow-up commit (5ee8a6c) to apply pre-commit formatting in tests/test_checkpoint.py .
Lint is now passing.
Could you please review when you have time?

Comment thread tests/test_checkpoint.py
@huan2088

Copy link
Copy Markdown

Hello! I'm new to the repository, and am looking for ways to contribute. I was wondering if I can be assigned this issue? Thank you!

sadamov added a commit to Jayant-kernel/neural-lam-gsoc- that referenced this pull request Jun 6, 2026
…rams (mllam#232)

Re-applies @Jayant-kernel's PR mllam#232 onto current main. The original test
targeted the pre-mllam#208 API (`GraphLAM(args=..., config=..., datastore=...)`
all on the top-level model). Rewritten for the post-mllam#208 layout: build a
GraphLAM step predictor + ARForecaster + ForecasterModule explicitly and
assert the ignore covers both heavy non-pickle-safe objects (`datastore`
and the now-additional `forecaster`).

Refs mllam#148.

Co-Authored-By: Jayant <Jayant-kernel@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sadamov
sadamov force-pushed the fix/148-datastore-checkpoint-regression branch from 35cb629 to a95956f Compare June 6, 2026 19:17
…rams (mllam#232)

Re-applies @Jayant-kernel's PR mllam#232 onto current main. The original test
targeted the pre-mllam#208 API (`GraphLAM(args=..., config=..., datastore=...)`
all on the top-level model). Rewritten for the post-mllam#208 layout: build a
GraphLAM step predictor + ARForecaster + ForecasterModule explicitly and
assert the ignore covers both heavy non-pickle-safe objects (`datastore`
and the now-additional `forecaster`).

Refs mllam#148.

Co-Authored-By: Jayant <Jayant-kernel@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sadamov
sadamov force-pushed the fix/148-datastore-checkpoint-regression branch from a95956f to 57b427f Compare June 6, 2026 19:23

@sadamov sadamov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @Jayant-kernel, sorry for the long wait! Rewrote the test for the post-#208 architecture (the original used GraphLAM(args=..., config=..., datastore=...) as a top-level model, which doesn't exist anymore). Renamed to test_saved_checkpoint_excludes_datastore_and_forecaster to honour @joeloskarsson's "more descriptive name" ask, and tightened the assertion to cover the now-additional forecaster field that's also in the ignore list. Merging after CI is green.

@sadamov
sadamov merged commit 96da198 into mllam:main Jun 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't pickle the datastore with the model checkpoint

5 participants