From 589c1ba4695349c0fa1bcb26e3de63cd02b4b6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huy=20=C4=90=E1=BB=97?= <56794124+Al3xDo@users.noreply.github.com> Date: Wed, 14 Dec 2022 19:16:38 +0700 Subject: [PATCH] Adding hint to the logger's error messages (#16034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com> Co-authored-by: Carlos MocholĂ­ Fixes https://github.com/Lightning-AI/lightning/issues/15143 --- .../trainer/connectors/logger_connector/fx_validator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pytorch_lightning/trainer/connectors/logger_connector/fx_validator.py b/src/pytorch_lightning/trainer/connectors/logger_connector/fx_validator.py index f1478ecbf9cbe..686d3a364cbf4 100644 --- a/src/pytorch_lightning/trainer/connectors/logger_connector/fx_validator.py +++ b/src/pytorch_lightning/trainer/connectors/logger_connector/fx_validator.py @@ -174,7 +174,10 @@ def check_logging(cls, fx_name: str) -> None: ) if cls.functions[fx_name] is None: - raise MisconfigurationException(f"You can't `self.log()` inside `{fx_name}`.") + raise MisconfigurationException( + f"You can't `self.log()` inside `{fx_name}`. HINT: You can still log directly to the logger by using" + " `self.logger.experiment`." + ) @classmethod def get_default_logging_levels(