1818from datetime import timedelta
1919from typing import Optional , Union
2020
21- from lightning_utilities import module_available
21+ from lightning_utilities . core . imports import RequirementCache
2222
2323import lightning .pytorch as pl
2424from lightning .fabric .utilities .registry import _load_external_callbacks
@@ -93,7 +93,7 @@ def _configure_checkpoint_callbacks(self, enable_checkpointing: bool) -> None:
9393 " but found `ModelCheckpoint` in callbacks list."
9494 )
9595 elif enable_checkpointing :
96- if module_available ("litmodels" ) and self .trainer ._model_registry :
96+ if RequirementCache ("litmodels >=0.1.7 " ) and self .trainer ._model_registry :
9797 trainer_source = inspect .getmodule (self .trainer )
9898 if trainer_source is None or not isinstance (trainer_source .__package__ , str ):
9999 raise RuntimeError ("Unable to determine the source of the trainer." )
@@ -103,12 +103,11 @@ def _configure_checkpoint_callbacks(self, enable_checkpointing: bool) -> None:
103103 else :
104104 from litmodels .integrations .checkpoints import LightningModelCheckpoint as LitModelCheckpoint
105105
106- model_checkpoint = LitModelCheckpoint (model_name = self .trainer ._model_registry )
106+ model_checkpoint = LitModelCheckpoint (model_registry = self .trainer ._model_registry )
107107 else :
108108 rank_zero_info (
109- "You are using the default ModelCheckpoint callback."
110- " Install `litmodels` package to use the `LitModelCheckpoint` instead"
111- " for seamless uploading to the Lightning model registry."
109+ "Using default `ModelCheckpoint`. Consider installing `litmodels` package to enable"
110+ " `LitModelCheckpoint` for automatic upload to the Lightning model registry."
112111 )
113112 model_checkpoint = ModelCheckpoint ()
114113 self .trainer .callbacks .append (model_checkpoint )
0 commit comments