Skip to content

Commit

Permalink
once
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Aug 20, 2024
1 parent 415e998 commit 11261a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 6 additions & 3 deletions python/langsmith/_internal/_beta_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ class LangSmithBetaWarning(UserWarning):
"""This is a warning specific to the LangSmithBeta module."""


@functools.lru_cache(maxsize=100)
def _warn_once(message: str) -> None:
warnings.warn(message, LangSmithBetaWarning, stacklevel=2)


def warn_beta(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(*args, **kwargs):
warnings.warn(
f"Function {func.__name__} is in beta.", LangSmithBetaWarning, stacklevel=2
)
_warn_once(f"Function {func.__name__} is in beta.")
return func(*args, **kwargs)

return wrapper
5 changes: 1 addition & 4 deletions python/langsmith/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import asyncio
import datetime
import uuid
import warnings
from typing import (
Any,
AsyncIterator,
Expand Down Expand Up @@ -47,9 +46,7 @@ def __init__(
retry_config: Optional[Mapping[str, Any]] = None,
):
"""Initialize the async client."""
warnings.warn(
"Class AsyncClient is in beta.", ls_beta.LangSmithBetaWarning, stacklevel=2
)
ls_beta._warn_once("Class AsyncClient is in beta.")
self._retry_config = retry_config or {"max_retries": 3}
_headers = {
"Content-Type": "application/json",
Expand Down

0 comments on commit 11261a9

Please sign in to comment.