Skip to content

Commit

Permalink
infra: Clear cache for env-var checks (#26073)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Sep 6, 2024
1 parent 854f37b commit 262e19b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
13 changes: 7 additions & 6 deletions libs/community/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/community/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PyYAML = ">=5.3"
aiohttp = "^3.8.3"
tenacity = "^8.1.0,!=8.4.0"
dataclasses-json = ">= 0.5.7, < 0.7"
langsmith = "^0.1.0"
langsmith = "^0.1.112"
[[tool.poetry.dependencies.numpy]]
version = "^1"
python = "<3.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain_core.outputs import LLMResult
from langchain_core.tracers.langchain import LangChainTracer, wait_for_all_tracers
from langchain_core.utils.pydantic import get_fields
from langsmith import utils as ls_utils

from langchain_community.callbacks import get_openai_callback
from langchain_community.callbacks.manager import get_bedrock_anthropic_callback
Expand All @@ -17,6 +18,8 @@ def test_callback_manager_configure_context_vars(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Test callback manager configuration."""
ls_utils.get_env_var.cache_clear()
ls_utils.get_tracer_project.cache_clear()
monkeypatch.setenv("LANGCHAIN_TRACING_V2", "true")
monkeypatch.setenv("LANGCHAIN_TRACING", "false")
monkeypatch.setenv("LANGCHAIN_API_KEY", "foo")
Expand Down
8 changes: 4 additions & 4 deletions libs/core/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ignore_missing_imports = true

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
langsmith = "^0.1.75"
langsmith = "^0.1.112"
tenacity = "^8.1.0,!=8.4.0"
jsonpatch = "^1.33"
PyYAML = ">=5.3"
Expand Down
3 changes: 3 additions & 0 deletions libs/core/tests/unit_tests/runnables/test_tracing_interops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from langsmith import Client, traceable
from langsmith.run_helpers import tracing_context
from langsmith.utils import get_env_var

from langchain_core.runnables.base import RunnableLambda, RunnableParallel
from langchain_core.tracers.langchain import LangChainTracer
Expand All @@ -31,6 +32,7 @@ def _get_posts(client: Client) -> list:


def test_config_traceable_handoff() -> None:
get_env_var.cache_clear()
mock_session = MagicMock()
mock_client_ = Client(
session=mock_session, api_key="test", auto_batch_tracing=False
Expand Down Expand Up @@ -186,6 +188,7 @@ def test_tracing_enable_disable(
def my_func(a: int) -> int:
return a + 1

get_env_var.cache_clear()
env_on = env == "true"
with patch.dict("os.environ", {"LANGSMITH_TRACING": env}):
with tracing_context(enabled=enabled):
Expand Down
3 changes: 3 additions & 0 deletions libs/core/tests/unit_tests/tracers/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest
from langsmith import Client
from langsmith.run_trees import RunTree
from langsmith.utils import get_env_var, get_tracer_project

from langchain_core.outputs import LLMResult
from langchain_core.tracers.langchain import LangChainTracer
Expand Down Expand Up @@ -130,6 +131,8 @@ def test_correct_get_tracer_project(self) -> None:
]

for case in cases:
get_env_var.cache_clear()
get_tracer_project.cache_clear()
with self.subTest(msg=case.test_name):
with pytest.MonkeyPatch.context() as mp:
for k, v in case.envvars.items():
Expand Down

0 comments on commit 262e19b

Please sign in to comment.