Unverified Commit 309cf025 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

python3Packages.langchain*: restore dependency on blockbuster, update (#402607)

parents 74928a15 ee2126ca
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
  tenacity,

  # tests
  blockbuster,
  httpx,
  langchain-tests,
  lark,
@@ -37,25 +38,20 @@

buildPythonPackage rec {
  pname = "langchain-community";
  version = "0.3.20";
  version = "0.3.22";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "langchain-ai";
    repo = "langchain";
    tag = "langchain-community==${version}";
    hash = "sha256-6YLy7G1kZIqHAGMUIQoGCfDO2ZuVgNEtpkOI1o8eFvc=";
    hash = "sha256-fotu3vUCWnAVyjFjsIUjk1If81yQ3/YLj26PksmnvGE=";
  };

  sourceRoot = "${src.name}/libs/community";

  build-system = [ pdm-backend ];

  patches = [
    # Remove dependency on blockbuster (not available in nixpkgs due to dependency on forbiddenfruit)
    ./rm-blockbuster.patch
  ];

  pythonRelaxDeps = [
    # Each component release requests the exact latest langchain and -core.
    # That prevents us from updating individul components.
@@ -66,10 +62,6 @@ buildPythonPackage rec {
    "tenacity"
  ];

  pythonRemoveDeps = [
    "blockbuster"
  ];

  dependencies = [
    aiohttp
    dataclasses-json
@@ -87,6 +79,7 @@ buildPythonPackage rec {
  pythonImportsCheck = [ "langchain_community" ];

  nativeCheckInputs = [
    blockbuster
    httpx
    langchain-tests
    lark
@@ -108,8 +101,6 @@ buildPythonPackage rec {
    # Test require network access
    "test_ovhcloud_embed_documents"
    "test_yandex"
    # duckdb-engine needs python-wasmer which is not yet available in Python 3.12
    # See https://github.com/NixOS/nixpkgs/pull/326337 and https://github.com/wasmerio/wasmer-python/issues/778
    "test_table_info"
    "test_sql_database_run"
    # pydantic.errors.PydanticUserError: `SQLDatabaseToolkit` is not fully defined; you should define `BaseCache`, then call `SQLDatabaseToolkit.model_rebuild()`.
@@ -118,19 +109,21 @@ buildPythonPackage rec {
    "test_proper_inputs"
    # pydantic.errors.PydanticUserError: `NatBotChain` is not fully defined; you should define `BaseCache`, then call `NatBotChain.model_rebuild()`.
    "test_variable_key_naming"
    # Fails due to the lack of blockbuster
    "test_group_dependencies"
    # Tests against magic values in dict
    "test_serializable_mapping"
  ];

  disabledTestPaths = [
    # ValueError: Received unsupported arguments {'strict': None}
    "tests/unit_tests/chat_models/test_cloudflare_workersai.py"
    # depends on Pydantic v1 notations, will not load
    "tests/unit_tests/document_loaders/test_gitbook.py"
  ];

  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--version-regex"
      "^langchain-community==(.*)"
      "langchain-community==([0-9.]+)"
    ];
  };

+0 −37
Original line number Diff line number Diff line
diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py
index 63f3a83e0..61c2d6ce3 100644
--- a/tests/unit_tests/conftest.py
+++ b/tests/unit_tests/conftest.py
@@ -5,22 +5,22 @@ from importlib import util
 from typing import Dict, Sequence
 
 import pytest
-from blockbuster import blockbuster_ctx
+# from blockbuster import blockbuster_ctx
 from pytest import Config, Function, Parser
 
 
-@pytest.fixture(autouse=True)
-def blockbuster() -> Iterator[None]:
-    with blockbuster_ctx("langchain_community") as bb:
-        (
-            bb.functions["os.stat"]
-            .can_block_in("langchain_community/utils/openai.py", "is_openai_v1")
-            .can_block_in("httpx/_client.py", "_init_transport")
-        )
-        bb.functions["os.path.abspath"].can_block_in(
-            "sqlalchemy/dialects/sqlite/pysqlite.py", "create_connect_args"
-        )
-        yield
+# @pytest.fixture(autouse=True)
+# def blockbuster() -> Iterator[None]:
+#     with blockbuster_ctx("langchain_community") as bb:
+#         (
+#             bb.functions["os.stat"]
+#             .can_block_in("langchain_community/utils/openai.py", "is_openai_v1")
+#             .can_block_in("httpx/_client.py", "_init_transport")
+#         )
+#         bb.functions["os.path.abspath"].can_block_in(
+#             "sqlalchemy/dialects/sqlite/pysqlite.py", "create_connect_args"
+#         )
+#         yield
+4 −11
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
  typing-extensions,

  # tests
  blockbuster,
  freezegun,
  grandalf,
  httpx,
@@ -32,31 +33,22 @@

buildPythonPackage rec {
  pname = "langchain-core";
  version = "0.3.49";
  version = "0.3.56";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "langchain-ai";
    repo = "langchain";
    tag = "langchain-core==${version}";
    hash = "sha256-s1vZ7G6Wzywf3euwX/RdCPkgzxvZTYVG0udGpHTIiQc=";
    hash = "sha256-gsjYr22Phb71oKN4iVGsi6r1iETDhFHCKKOiwp0SuLU=";
  };

  sourceRoot = "${src.name}/libs/core";

  patches = [
    # Remove dependency on blockbuster (not available in nixpkgs due to dependency on forbiddenfruit)
    ./rm-blockbuster.patch
  ];

  build-system = [ pdm-backend ];

  pythonRelaxDeps = [ "tenacity" ];

  pythonRemoveDependencies = [
    "blockbuster"
  ];

  dependencies = [
    jsonpatch
    langsmith
@@ -73,6 +65,7 @@ buildPythonPackage rec {
  doCheck = false;

  nativeCheckInputs = [
    blockbuster
    freezegun
    grandalf
    httpx
+0 −155
Original line number Diff line number Diff line
diff --git a/pyproject.toml b/pyproject.toml
index a2cfc7adf..db37bd74a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,7 +53,7 @@ test = [
     "responses<1.0.0,>=0.25.0",
     "pytest-socket<1.0.0,>=0.7.0",
     "pytest-xdist<4.0.0,>=3.6.1",
-    "blockbuster~=1.5.18",
+    # "blockbuster~=1.5.18",
     "numpy<2.0.0,>=1.24.0; python_version < \"3.12\"",
     "numpy<3,>=1.26.0; python_version >= \"3.12\"",
     "langchain-tests",
diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py
index 6438c3037..aa301c337 100644
--- a/tests/unit_tests/conftest.py
+++ b/tests/unit_tests/conftest.py
@@ -5,35 +5,35 @@ from importlib import util
 from uuid import UUID
 
 import pytest
-from blockbuster import BlockBuster, blockbuster_ctx
+# from blockbuster import BlockBuster, blockbuster_ctx
 from pytest import Config, Function, Parser
 from pytest_mock import MockerFixture
 
 
-@pytest.fixture(autouse=True)
-def blockbuster() -> Iterator[BlockBuster]:
-    with blockbuster_ctx("langchain_core") as bb:
-        for func in ["os.stat", "os.path.abspath"]:
-            (
-                bb.functions[func]
-                .can_block_in("langchain_core/_api/internal.py", "is_caller_internal")
-                .can_block_in("langchain_core/runnables/base.py", "__repr__")
-                .can_block_in(
-                    "langchain_core/beta/runnables/context.py", "aconfig_with_context"
-                )
-            )
-
-        for func in ["os.stat", "io.TextIOWrapper.read"]:
-            bb.functions[func].can_block_in(
-                "langsmith/client.py", "_default_retry_config"
-            )
-
-        for bb_function in bb.functions.values():
-            bb_function.can_block_in(
-                "freezegun/api.py", "_get_cached_module_attributes"
-            )
-
-        yield bb
+# @pytest.fixture(autouse=True)
+# def blockbuster() -> Iterator[BlockBuster]:
+#     with blockbuster_ctx("langchain_core") as bb:
+#         for func in ["os.stat", "os.path.abspath"]:
+#             (
+#                 bb.functions[func]
+#                 .can_block_in("langchain_core/_api/internal.py", "is_caller_internal")
+#                 .can_block_in("langchain_core/runnables/base.py", "__repr__")
+#                 .can_block_in(
+#                     "langchain_core/beta/runnables/context.py", "aconfig_with_context"
+#                 )
+#             )
+
+#         for func in ["os.stat", "io.TextIOWrapper.read"]:
+#             bb.functions[func].can_block_in(
+#                 "langsmith/client.py", "_default_retry_config"
+#             )
+
+#         for bb_function in bb.functions.values():
+#             bb_function.can_block_in(
+#                 "freezegun/api.py", "_get_cached_module_attributes"
+#             )
+
+#         yield bb
 
 
 def pytest_addoption(parser: Parser) -> None:
diff --git a/tests/unit_tests/language_models/chat_models/test_rate_limiting.py b/tests/unit_tests/language_models/chat_models/test_rate_limiting.py
index ee6eefba9..4d39da58d 100644
--- a/tests/unit_tests/language_models/chat_models/test_rate_limiting.py
+++ b/tests/unit_tests/language_models/chat_models/test_rate_limiting.py
@@ -2,17 +2,17 @@ import time
 from typing import Optional as Optional
 
 import pytest
-from blockbuster import BlockBuster
+# from blockbuster import BlockBuster
 
 from langchain_core.caches import InMemoryCache
 from langchain_core.language_models import GenericFakeChatModel
 from langchain_core.rate_limiters import InMemoryRateLimiter
 
 
-@pytest.fixture(autouse=True)
-def deactivate_blockbuster(blockbuster: BlockBuster) -> None:
-    # Deactivate BlockBuster to not disturb the rate limiter timings
-    blockbuster.deactivate()
+# @pytest.fixture(autouse=True)
+# def deactivate_blockbuster(blockbuster: BlockBuster) -> None:
+#     # Deactivate BlockBuster to not disturb the rate limiter timings
+#     blockbuster.deactivate()
 
 
 def test_rate_limit_invoke() -> None:
diff --git a/tests/unit_tests/runnables/test_runnable_events_v2.py b/tests/unit_tests/runnables/test_runnable_events_v2.py
index e1e1f37b9..21d2f1600 100644
--- a/tests/unit_tests/runnables/test_runnable_events_v2.py
+++ b/tests/unit_tests/runnables/test_runnable_events_v2.py
@@ -15,7 +15,7 @@ from typing import (
 )
 
 import pytest
-from blockbuster import BlockBuster
+# from blockbuster import BlockBuster
 from pydantic import BaseModel
 
 from langchain_core.callbacks import CallbackManagerForRetrieverRun, Callbacks
@@ -2005,7 +2005,7 @@ EXPECTED_EVENTS = [
 
 async def test_sync_in_async_stream_lambdas(blockbuster: BlockBuster) -> None:
     """Test invoking nested runnable lambda."""
-    blockbuster.deactivate()
+    # blockbuster.deactivate()
 
     def add_one(x: int) -> int:
         return x + 1
diff --git a/tests/unit_tests/test_setup.py b/tests/unit_tests/test_setup.py
index 1df3c73a2..58e94de9a 100644
--- a/tests/unit_tests/test_setup.py
+++ b/tests/unit_tests/test_setup.py
@@ -1,15 +1,15 @@
 import time
 
 import pytest
-from blockbuster import BlockingError
+# from blockbuster import BlockingError
 
 from langchain_core import sys_info
 
 
-async def test_blockbuster_setup() -> None:
-    """Check if blockbuster is correctly setup."""
-    # Blocking call outside of langchain_core is allowed.
-    time.sleep(0.01)  # noqa: ASYNC251
-    with pytest.raises(BlockingError):
-        # Blocking call from langchain_core raises BlockingError.
-        sys_info.print_sys_info()
+# async def test_blockbuster_setup() -> None:
+#     """Check if blockbuster is correctly setup."""
+#     # Blocking call outside of langchain_core is allowed.
+#     time.sleep(0.01)  # noqa: ASYNC251
+#     with pytest.raises(BlockingError):
+#         # Blocking call from langchain_core raises BlockingError.
+#         sys_info.print_sys_info()
+4 −11
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
  tenacity,

  # tests
  blockbuster,
  freezegun,
  httpx,
  lark,
@@ -41,7 +42,7 @@

buildPythonPackage rec {
  pname = "langchain";
  version = "0.3.21";
  version = "0.3.24";
  pyproject = true;

  src = fetchFromGitHub {
@@ -53,11 +54,6 @@ buildPythonPackage rec {

  sourceRoot = "${src.name}/libs/langchain";

  patches = [
    # blockbuster isn't supported in nixpkgs
    ./rm-blockbuster.patch
  ];

  build-system = [ pdm-backend ];

  buildInputs = [ bash ];
@@ -70,10 +66,6 @@ buildPythonPackage rec {
    "tenacity"
  ];

  pythonRemoveDeps = [
    "blockbuster"
  ];

  dependencies = [
    aiohttp
    langchain-core
@@ -92,6 +84,7 @@ buildPythonPackage rec {
  };

  nativeCheckInputs = [
    blockbuster
    freezegun
    httpx
    lark
@@ -151,7 +144,7 @@ buildPythonPackage rec {
  passthru.updateScript = nix-update-script {
    extraArgs = [
      "--version-regex"
      "^langchain==([0-9.]+)$"
      "langchain==([0-9.]+)"
    ];
  };

Loading