From b2cd5a1e38a42eeb5085c8c11f7e803e832ed887 Mon Sep 17 00:00:00 2001 From: Richard Rogers Date: Thu, 26 Sep 2024 00:44:21 +0000 Subject: [PATCH 1/3] deprecate debug event argument --- python/whylogs/api/logger/__init__.py | 2 ++ python/whylogs/core/utils/__init__.py | 3 ++- python/whylogs/core/utils/utils.py | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/python/whylogs/api/logger/__init__.py b/python/whylogs/api/logger/__init__.py index c355476b9a..a341a7966f 100644 --- a/python/whylogs/api/logger/__init__.py +++ b/python/whylogs/api/logger/__init__.py @@ -31,12 +31,14 @@ ModelPerformanceMetrics, ) from whylogs.core.stubs import pd +from whylogs.core.utils import deprecated_argument diagnostic_logger = logging.getLogger(__name__) Loggable = Union["pd.DataFrame", List[Dict[str, Any]]] +@deprecated_argument("debug_event") def log( obj: Any = None, *, diff --git a/python/whylogs/core/utils/__init__.py b/python/whylogs/core/utils/__init__.py index 6bb886f330..5b3c588522 100644 --- a/python/whylogs/core/utils/__init__.py +++ b/python/whylogs/core/utils/__init__.py @@ -4,7 +4,7 @@ get_distribution_metrics, is_probably_unique, ) -from .utils import deprecated, deprecated_alias, ensure_timezone +from .utils import deprecated, deprecated_alias, deprecated_argument, ensure_timezone __ALL__ = [ # read_delimited_protobuf, @@ -13,6 +13,7 @@ is_probably_unique, get_cardinality_estimate, deprecated_alias, + deprecated_argument, deprecated, ensure_timezone, # ] diff --git a/python/whylogs/core/utils/utils.py b/python/whylogs/core/utils/utils.py index 4ebebbd8fb..418604f2cd 100644 --- a/python/whylogs/core/utils/utils.py +++ b/python/whylogs/core/utils/utils.py @@ -1,7 +1,7 @@ import datetime import functools import warnings -from typing import Any, Callable, Dict +from typing import Any, Callable, Dict, Optional from urllib.parse import urlparse from urllib3 import util @@ -32,6 +32,19 @@ def wrapper(*args, **kwargs): return deprecated_decorator +def deprecated_argument(arg_name: str, message: Optional[str] = None): + def deprecated_decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + if arg_name in kwargs: + warnings.warn(f"Argument {arg_name} is deprecated, {message if message else 'do not use it'}.") + return func(*args, **kwargs) + + return wrapper + + return deprecated_decorator + + def rename_kwargs(func_name: str, kwargs: Dict[str, Any], aliases: Dict[str, str]) -> None: for alias, new in aliases.items(): if alias in kwargs: From 06cac52420f8a699db8dea6f4758fd60faa83b9d Mon Sep 17 00:00:00 2001 From: richard-rogers <93153899+richard-rogers@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:51:40 +0100 Subject: [PATCH 2/3] Update python/whylogs/core/utils/utils.py --- python/whylogs/core/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/whylogs/core/utils/utils.py b/python/whylogs/core/utils/utils.py index 418604f2cd..dab7cdd42e 100644 --- a/python/whylogs/core/utils/utils.py +++ b/python/whylogs/core/utils/utils.py @@ -37,7 +37,7 @@ def deprecated_decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): if arg_name in kwargs: - warnings.warn(f"Argument {arg_name} is deprecated, {message if message else 'do not use it'}.") + warnings.warn(f"Argument {arg_name} is deprecated, {message if message else 'it will be removed in the next major version of whylogs'}.") return func(*args, **kwargs) return wrapper From 8c040b6abacc2c0a97080c347ea0b9cf80cb76b0 Mon Sep 17 00:00:00 2001 From: Richard Rogers Date: Thu, 26 Sep 2024 21:54:33 +0000 Subject: [PATCH 3/3] pre-commit --- python/whylogs/core/utils/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/whylogs/core/utils/utils.py b/python/whylogs/core/utils/utils.py index dab7cdd42e..82734f34a9 100644 --- a/python/whylogs/core/utils/utils.py +++ b/python/whylogs/core/utils/utils.py @@ -37,7 +37,9 @@ def deprecated_decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): if arg_name in kwargs: - warnings.warn(f"Argument {arg_name} is deprecated, {message if message else 'it will be removed in the next major version of whylogs'}.") + warnings.warn( + f"Argument {arg_name} is deprecated, {message if message else 'it will be removed in the next major version of whylogs'}." + ) return func(*args, **kwargs) return wrapper