Skip to content

Commit

Permalink
Batching Fix (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Feb 25, 2024
1 parent a395085 commit 86c2a44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ def batch_ingest_runs(
if body_size > 0 and body_size + len(body[0]) > size_limit_bytes:
self._post_batch_ingest_runs(orjson.dumps(body_chunks))
body_size = 0
body_chunks.clear()
body_size += len(body[0])
body_chunks[key].append(orjson.Fragment(body.popleft()))
if body_size:
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.1.7"
version = "0.1.8"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <[email protected]>"]
license = "MIT"
Expand Down
8 changes: 3 additions & 5 deletions python/tests/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,11 +803,6 @@ def test_batch_ingest_run_splits_large_batches(payload_size: int):
sum([1 for call in mock_session.request.call_args_list if call[0][0] == "post"])
== expected_num_requests
)

# Use orjson to reload all the post request bodies and check that all the
# post/patch requests are present in the request bodies
import orjson

request_bodies = [
op
for call in mock_session.request.call_args_list
Expand All @@ -819,3 +814,6 @@ def test_batch_ingest_run_splits_large_batches(payload_size: int):
# Check that all the run_ids are present in the request bodies
for run_id in all_run_ids:
assert any([body["id"] == str(run_id) for body in request_bodies])

# Check that no duplicate run_ids are present in the request bodies
assert len(request_bodies) == len(set([body["id"] for body in request_bodies]))

0 comments on commit 86c2a44

Please sign in to comment.