diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cf37317..0a044324 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ # Changelog All notable changes to this project will be documented in this file. +### [1.1.2] + +#### Fixed + +- Fix best checkpoint not used for testing when available in `LightningTask` class. + ### [1.1.1] #### Fixed diff --git a/pyproject.toml b/pyproject.toml index 6186f14b..fe077e20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "quadra" -version = "1.1.1" +version = "1.1.2" description = "Deep Learning experiment orchestration library" authors = [ {name = "Alessandro Polidori", email = "alessandro.polidori@orobix.com"}, @@ -117,7 +117,7 @@ repository = "https://github.com/orobix/quadra" # Adapted from https://realpython.com/pypi-publish-python-package/#version-your-package [tool.bumpver] -current_version = "1.1.1" +current_version = "1.1.2" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "build: Bump version {old_version} -> {new_version}" commit = true diff --git a/quadra/__init__.py b/quadra/__init__.py index 689f56c0..49fcf021 100644 --- a/quadra/__init__.py +++ b/quadra/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.1.1" +__version__ = "1.1.2" def get_version(): diff --git a/quadra/tasks/base.py b/quadra/tasks/base.py index 3b0f1ed5..5ea6f820 100644 --- a/quadra/tasks/base.py +++ b/quadra/tasks/base.py @@ -257,7 +257,22 @@ def train(self) -> None: def test(self) -> Any: """Test the model.""" log.info("Starting testing!") - return self.trainer.test(model=self.module, datamodule=self.datamodule) + + best_model = None + if ( + self.trainer.checkpoint_callback is not None + and hasattr(self.trainer.checkpoint_callback, "best_model_path") + and self.trainer.checkpoint_callback.best_model_path is not None + ): + best_model = self.trainer.checkpoint_callback.best_model_path + + if best_model is None: + log.warning( + "No best checkpoint model found, using last weights for test, this might lead to worse results, " + "consider using a checkpoint callback." + ) + + return self.trainer.test(model=self.module, datamodule=self.datamodule, ckpt_path=best_model) def finalize(self) -> None: """Finalize the experiment."""