Skip to content

Commit

Permalink
deprecate debug event argument
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-rogers committed Sep 26, 2024
1 parent 4ad4cc9 commit b2cd5a1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/whylogs/api/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down
3 changes: 2 additions & 1 deletion python/whylogs/core/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,6 +13,7 @@
is_probably_unique,
get_cardinality_estimate,
deprecated_alias,
deprecated_argument,
deprecated,
ensure_timezone, #
]
15 changes: 14 additions & 1 deletion python/whylogs/core/utils/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b2cd5a1

Please sign in to comment.