infra: Clear cache for env-var checks (#26073)

This commit is contained in:
William FH 2024-09-06 14:29:29 -07:00 committed by GitHub
parent 854f37be87
commit 262e19b15d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 22 additions and 12 deletions

View File

@ -1772,7 +1772,7 @@ develop = true
[package.dependencies]
jsonpatch = "^1.33"
langsmith = "^0.1.75"
langsmith = "^0.1.112"
packaging = ">=23.2,<25"
pydantic = [
{version = ">=1,<3", markers = "python_full_version < \"3.12.4\""},
@ -1799,6 +1799,7 @@ develop = true
httpx = "^0.27.0"
langchain-core = ">=0.1.40,<0.3"
pytest = ">=7,<9"
syrupy = "^4"
[package.source]
type = "directory"
@ -1822,13 +1823,13 @@ url = "../text-splitters"
[[package]]
name = "langsmith"
version = "0.1.110"
version = "0.1.116"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
optional = false
python-versions = "<4.0,>=3.8.1"
files = [
{file = "langsmith-0.1.110-py3-none-any.whl", hash = "sha256:316d279e3853f5e90e462f9c035eeb468d042f2a21a269c1102d65f3dccdc334"},
{file = "langsmith-0.1.110.tar.gz", hash = "sha256:9a619dfe22a67a05a05091f0677b9c842499faec5f051b31afcd901b6627d0a3"},
{file = "langsmith-0.1.116-py3-none-any.whl", hash = "sha256:4b5ea64c81ba5ca309695c85dc3fb4617429a985129ed5d9eca00d1c9d6483f4"},
{file = "langsmith-0.1.116.tar.gz", hash = "sha256:5ccd7f5c1840f7c507ab3ee56334a1391de28c8bf72669782e2d82cafeefffa7"},
]
[package.dependencies]
@ -2481,8 +2482,8 @@ files = [
[package.dependencies]
numpy = [
{version = ">=1.20.3", markers = "python_version < \"3.10\""},
{version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""},
{version = ">=1.23.2", markers = "python_version >= \"3.11\""},
{version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""},
]
python-dateutil = ">=2.8.2"
pytz = ">=2020.1"
@ -4323,4 +4324,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<4.0"
content-hash = "b69b2186cc152c64945d8000e883e92d7872a38b7113f60b1db5c7e1c9aed7c6"
content-hash = "83bd930c36648406317fb87fa8205f67e41c89b27c30cb25b9e66a476d0e5e08"

View File

@ -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"

View File

@ -7,6 +7,7 @@ from langchain_core.callbacks.manager import CallbackManager, trace_as_chain_gro
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
@ -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")

8
libs/core/poetry.lock generated
View File

@ -1253,13 +1253,13 @@ url = "../text-splitters"
[[package]]
name = "langsmith"
version = "0.1.106"
version = "0.1.113"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
optional = false
python-versions = "<4.0,>=3.8.1"
files = [
{file = "langsmith-0.1.106-py3-none-any.whl", hash = "sha256:a418161c98de72ee2c6eea6667c6217814b67db4b9a3a024788013384216ff35"},
{file = "langsmith-0.1.106.tar.gz", hash = "sha256:64a890a05640d64692f5515ebb444b0457332a9cf9e7605c4651de6737a7d3a0"},
{file = "langsmith-0.1.113-py3-none-any.whl", hash = "sha256:0071d034fbe54cc3574f382b062c4b4f09931dfe7b703146900b7918a7f6c785"},
{file = "langsmith-0.1.113.tar.gz", hash = "sha256:369efa53352bdc4f27d5c8b7f4f802b32492e55511c7fbeeaea143dbfdf0ee06"},
]
[package.dependencies]
@ -3220,4 +3220,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<4.0"
content-hash = "e86e28d75744b77f8c2173b58e950c2d23c95cacad8ee5d3110309c4248f7c09"
content-hash = "db22fd24cc4409baa802efebb4a73e8effd50befe465428d7946d91dccbb9563"

View File

@ -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"

View File

@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch
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
@ -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
@ -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):

View File

@ -9,6 +9,7 @@ from uuid import UUID
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
@ -130,6 +131,8 @@ class LangChainProjectNameTest(unittest.TestCase):
]
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():