Skip to content

Commit

Permalink
chore: adding warning about experimental feature
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
  • Loading branch information
aarnphm committed Oct 26, 2022
1 parent f4835bf commit ed770b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/bentoml/_internal/utils/__init__.py
Expand Up @@ -69,7 +69,7 @@
_EXPERIMENTAL_APIS: set[str] = set()


def _warn_experimental(api_name: str) -> None:
def warn_experimental(api_name: str) -> None:
if api_name not in _EXPERIMENTAL_APIS:
_EXPERIMENTAL_APIS.add(api_name)
msg = "'%s' is an EXPERIMENTAL API and is currently not yet stable. Proceed with caution!"
Expand All @@ -86,7 +86,7 @@ def experimental(
def decorator(func: t.Callable[..., t.Any]) -> t.Callable[P, t.Any]:
@functools.wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> t.Any:
_warn_experimental(api_name)
warn_experimental(api_name)
return func(*args, **kwargs)

return wrapper
Expand Down
7 changes: 6 additions & 1 deletion src/bentoml/metrics.py
Expand Up @@ -7,7 +7,7 @@
from simple_di import inject
from simple_di import Provide

from ._internal.utils import _warn_experimental
from ._internal.utils import warn_experimental
from ._internal.utils import add_experimental_docstring

if TYPE_CHECKING:
Expand Down Expand Up @@ -35,8 +35,13 @@ def __init__(self, attr: t.Any):
def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
"""
Lazily initialize the metrics object.
Args:
*args: Arguments to pass to the metrics object.
**kwargs: Keyword arguments to pass to the metrics object.
"""
# This is where we lazy load the proxy object.
warn_experimental("%s.%s" % (__name__, self._attr))
self._args = args
self._kwargs = kwargs
return self
Expand Down

0 comments on commit ed770b7

Please sign in to comment.