diff --git a/src/neptune_fastai/impl/__init__.py b/src/neptune_fastai/impl/__init__.py index 2ca1a31..7107b7c 100644 --- a/src/neptune_fastai/impl/__init__.py +++ b/src/neptune_fastai/impl/__init__.py @@ -154,14 +154,16 @@ def _batch_size(self) -> int: @property def _optimizer_name(self) -> Optional[str]: - optim_name = getattr(self.opt_func, "__name__", "N/A") - warning_msg = ( - "NeptuneCallback: Couldn't retrieve the optimizer name, " - "so it will be logged as 'N/A'. You can set the optimizer " - "name by assigning it to the __name__ attribute. " - "Eg. >>> optimizer.__name__ = 'NAME'" - ) - warnings.warn(warning_msg) + NA = "N/A" + optim_name = getattr(self.opt_func, "__name__", NA) + if optim_name == NA: + warning_msg = ( + "NeptuneCallback: Couldn't retrieve the optimizer name, " + "so it will be logged as 'N/A'. You can set the optimizer " + "name by assigning it to the __name__ attribute. " + "Eg. >>> optimizer.__name__ = 'NAME'" + ) + warnings.warn(warning_msg) return optim_name @property