From ac98491e6d81ab9f79f205672490b17d4f7ef6a1 Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 11 Jul 2024 19:24:19 +0200 Subject: [PATCH] feat(framework) Introduce a new deprecation function that warns users and provides an code example (#3776) Co-authored-by: Daniel J. Beutel --- src/py/flwr/common/logger.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/py/flwr/common/logger.py b/src/py/flwr/common/logger.py index f36ea2c1ce27..2077f9beaca0 100644 --- a/src/py/flwr/common/logger.py +++ b/src/py/flwr/common/logger.py @@ -197,6 +197,31 @@ def warn_deprecated_feature(name: str) -> None: ) +def warn_deprecated_feature_with_example( + deprecation_message: str, example_message: str, code_example: str +) -> None: + """Warn if a feature is deprecated and show code example.""" + log( + WARN, + """DEPRECATED FEATURE: %s + + Check the following `FEATURE UPDATE` warning message for the preferred + new mechanism to use this feature in Flower. + """, + deprecation_message, + ) + log( + WARN, + """FEATURE UPDATE: %s + ------------------------------------------------------------ + %s + ------------------------------------------------------------ + """, + example_message, + code_example, + ) + + def warn_unsupported_feature(name: str) -> None: """Warn the user when they use an unsupported feature.""" log(