From fdb9b9b8e02a63f5cc4cf930a3ea5af29dca189b Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Wed, 9 Apr 2025 11:31:33 -0400 Subject: [PATCH] checkpoint-postgres: add deprecation warning for ShallowPostgresSaver (#4219) --- .../langgraph/checkpoint/postgres/shallow.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py index 90e140b2c..9fe9bfdf8 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py @@ -1,5 +1,6 @@ import asyncio import threading +import warnings from collections.abc import AsyncIterator, Iterator, Sequence from contextlib import asynccontextmanager, contextmanager from typing import Any, Optional @@ -150,7 +151,7 @@ def _dump_blobs( checkpoint_ns: str, values: dict[str, Any], versions: ChannelVersions, -) -> list[tuple[str, str, str, str, str, Optional[bytes]]]: +) -> list[tuple[str, str, str, str, Optional[bytes]]]: if not versions: return [] @@ -188,6 +189,12 @@ class ShallowPostgresSaver(BasePostgresSaver): pipe: Optional[Pipeline] = None, serde: Optional[SerializerProtocol] = None, ) -> None: + warnings.warn( + "ShallowPostgresSaver is deprecated as of version 2.0.20 and will be removed in 3.0.0. " + "Use PostgresSaver instead, and invoke the graph with `graph.invoke(..., checkpoint_during=False)`.", + DeprecationWarning, + stacklevel=2, + ) super().__init__(serde=serde) if isinstance(conn, ConnectionPool) and pipe is not None: raise ValueError( @@ -528,6 +535,12 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): pipe: Optional[AsyncPipeline] = None, serde: Optional[SerializerProtocol] = None, ) -> None: + warnings.warn( + "AsyncShallowPostgresSaver is deprecated as of version 2.0.20 and will be removed in 3.0.0. " + "Use AsyncPostgresSaver instead, and invoke the graph with `await graph.ainvoke(..., checkpoint_during=False)`.", + DeprecationWarning, + stacklevel=2, + ) super().__init__(serde=serde) if isinstance(conn, AsyncConnectionPool) and pipe is not None: raise ValueError(