Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate debug event argument #1569

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
richard-rogers marked this conversation as resolved.
Show resolved Hide resolved
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, #
]
17 changes: 16 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,21 @@ 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 'it will be removed in the next major version of whylogs'}."
)
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
Loading