Skip to content

Commit

Permalink
Limit blockbuster to calls originated from langchain_core
Browse files Browse the repository at this point in the history
  • Loading branch information
cbornet committed Jan 30, 2025
1 parent 36ac6bf commit d360b33
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
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 @@ -118,7 +118,7 @@ grandalf = "^0.8"
responses = "^0.25.0"
pytest-socket = "^0.7.0"
pytest-xdist = "^3.6.1"
blockbuster = "~1.5.9"
blockbuster = "~1.5.11"
[[tool.poetry.group.test.dependencies.numpy]]
version = "^1.24.0"
python = "<3.12"
Expand Down
2 changes: 1 addition & 1 deletion libs/core/tests/unit_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@pytest.fixture(autouse=True)
def blockbuster() -> Iterator[BlockBuster]:
with blockbuster_ctx() as bb:
with blockbuster_ctx("langchain_core") as bb:
for func in ["os.stat", "os.path.abspath"]:
(
bb.functions[func]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ def _check_posts(self) -> None:
"other_thing": "RunnableParallel<chain_result,other_thing>",
"after": "RunnableSequence",
}
assert len(posts) == sum(1 if isinstance(n, str) else len(n) for n in name_order)
assert len(posts) == sum(
1 if isinstance(n, str) else len(n) for n in name_order
)
prev_dotted_order = None
dotted_order_map = {}
id_map = {}
Expand Down
15 changes: 15 additions & 0 deletions libs/core/tests/unit_tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import time

import pytest
from blockbuster import BlockingError

from langchain_core import sys_info


async def test_blockbuster_setup():
"""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()

0 comments on commit d360b33

Please sign in to comment.