Skip to content

Commit 980946a

Browse files
Fix faulty test and address langgraph checkpoint 2.1.0 issues
1 parent 02936cb commit 980946a

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

langgraph/checkpoint/redis/aio.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,18 +760,30 @@ async def aput_writes(
760760
exists = await self._redis.exists(key)
761761
if exists:
762762
# Update existing key
763-
await self._redis.json().set(key, "$.channel", write_obj["channel"]) # type: ignore[misc, arg-type]
764-
await self._redis.json().set(key, "$.type", write_obj["type"]) # type: ignore[misc, arg-type]
765-
await self._redis.json().set(key, "$.blob", write_obj["blob"]) # type: ignore[misc, arg-type]
763+
pipeline.json().set(
764+
key,
765+
"$.channel",
766+
write_obj["channel"], # type: ignore[arg-type]
767+
)
768+
pipeline.json().set(
769+
key,
770+
"$.type",
771+
write_obj["type"], # type: ignore[arg-type]
772+
)
773+
pipeline.json().set(
774+
key,
775+
"$.blob",
776+
write_obj["blob"], # type: ignore[arg-type]
777+
)
766778
else:
767779
# Create new key
768-
await self._redis.json().set(key, "$", write_obj) # type: ignore[misc]
780+
pipeline.json().set(key, "$", write_obj)
769781
created_keys.append(key)
770782
else:
771783
# For non-upsert case, only set if key doesn't exist
772784
exists = await self._redis.exists(key)
773785
if not exists:
774-
await self._redis.json().set(key, "$", write_obj) # type: ignore[misc]
786+
pipeline.json().set(key, "$", write_obj)
775787
created_keys.append(key)
776788

777789
# Execute all operations atomically

langgraph/checkpoint/redis/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ def _dump_metadata(self, metadata: CheckpointMetadata) -> str:
383383
# NOTE: we're using JSON serializer (not msgpack), so we need to remove null characters before writing
384384
return serialized_metadata.decode().replace("\\u0000", "")
385385

386-
def get_next_version(self, current: Optional[str], channel: None = None) -> str:
386+
def get_next_version( # type: ignore[override]
387+
self, current: Optional[str], channel: ChannelProtocol[Any, Any, Any]
388+
) -> str:
387389
"""Generate next version number."""
388390
if current is None:
389391
current_v = 0

poetry.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_interruption.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ async def test_aput_writes_interruption(redis_url: str) -> None:
420420

421421
# Either there are no pending writes or they are not the ones we tried to save
422422
if checkpoint_tuple and checkpoint_tuple.pending_writes:
423+
print(checkpoint_tuple.pending_writes, flush=True)
423424
for write in checkpoint_tuple.pending_writes:
424-
assert write.channel not in [
425+
assert write[1] not in [
425426
"channel1",
426427
"channel2",
427428
], "Transaction should have been rolled back"

0 commit comments

Comments
 (0)