From 1621d6446e3e99927e2cdaac8d0d81b3a3785edb 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 (cherry picked from commit 7ce3825f6dc5fea57ccd7d2cffe1ccd0f870cd7f) --- .../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 f1478ecbf9cbe5..686d3a364cbf43 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(