langgraph-checkpoint-postgres 2.0.11__tar.gz → 2.0.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (14) hide show
  1. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/PKG-INFO +2 -2
  2. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/__init__.py +2 -0
  3. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/aio.py +6 -2
  4. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/base.py +9 -6
  5. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/shallow.py +15 -6
  6. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/pyproject.toml +2 -2
  7. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/README.md +0 -0
  8. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/_ainternal.py +0 -0
  9. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/_internal.py +0 -0
  10. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/checkpoint/postgres/py.typed +0 -0
  11. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/store/postgres/__init__.py +0 -0
  12. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/store/postgres/aio.py +0 -0
  13. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/store/postgres/base.py +0 -0
  14. {langgraph_checkpoint_postgres-2.0.11 → langgraph_checkpoint_postgres-2.0.12}/langgraph/store/postgres/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langgraph-checkpoint-postgres
3
- Version: 2.0.11
3
+ Version: 2.0.12
4
4
  Summary: Library with a Postgres implementation of LangGraph checkpoint saver.
5
5
  Home-page: https://www.github.com/langchain-ai/langgraph
6
6
  License: MIT
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
- Requires-Dist: langgraph-checkpoint (>=2.0.7,<3.0.0)
14
+ Requires-Dist: langgraph-checkpoint (>=2.0.10,<3.0.0)
15
15
  Requires-Dist: orjson (>=3.10.1)
16
16
  Requires-Dist: psycopg (>=3.2.0,<4.0.0)
17
17
  Requires-Dist: psycopg-pool (>=3.2.0,<4.0.0)
@@ -327,6 +327,7 @@ class PostgresSaver(BasePostgresSaver):
327
327
  config: RunnableConfig,
328
328
  writes: Sequence[tuple[str, Any]],
329
329
  task_id: str,
330
+ task_path: str = "",
330
331
  ) -> None:
331
332
  """Store intermediate writes linked to a checkpoint.
332
333
 
@@ -350,6 +351,7 @@ class PostgresSaver(BasePostgresSaver):
350
351
  config["configurable"]["checkpoint_ns"],
351
352
  config["configurable"]["checkpoint_id"],
352
353
  task_id,
354
+ task_path,
353
355
  writes,
354
356
  ),
355
357
  )
@@ -285,6 +285,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
285
285
  config: RunnableConfig,
286
286
  writes: Sequence[tuple[str, Any]],
287
287
  task_id: str,
288
+ task_path: str = "",
288
289
  ) -> None:
289
290
  """Store intermediate writes linked to a checkpoint asynchronously.
290
291
 
@@ -306,6 +307,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
306
307
  config["configurable"]["checkpoint_ns"],
307
308
  config["configurable"]["checkpoint_id"],
308
309
  task_id,
310
+ task_path,
309
311
  writes,
310
312
  )
311
313
  async with self._cursor(pipeline=True) as cur:
@@ -385,7 +387,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
385
387
  # we don't check in other methods to avoid the overhead
386
388
  if asyncio.get_running_loop() is self.loop:
387
389
  raise asyncio.InvalidStateError(
388
- "Synchronous calls to AsyncSqliteSaver are only allowed from a "
390
+ "Synchronous calls to AsyncPostgresSaver are only allowed from a "
389
391
  "different thread. From the main thread, use the async interface. "
390
392
  "For example, use `checkpointer.alist(...)` or `await "
391
393
  "graph.ainvoke(...)`."
@@ -462,6 +464,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
462
464
  config: RunnableConfig,
463
465
  writes: Sequence[tuple[str, Any]],
464
466
  task_id: str,
467
+ task_path: str = "",
465
468
  ) -> None:
466
469
  """Store intermediate writes linked to a checkpoint.
467
470
 
@@ -471,9 +474,10 @@ class AsyncPostgresSaver(BasePostgresSaver):
471
474
  config (RunnableConfig): Configuration of the related checkpoint.
472
475
  writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair.
473
476
  task_id (str): Identifier for the task creating the writes.
477
+ task_path (str): Path of the task creating the writes.
474
478
  """
475
479
  return asyncio.run_coroutine_threadsafe(
476
- self.aput_writes(config, writes, task_id), self.loop
480
+ self.aput_writes(config, writes, task_id, task_path), self.loop
477
481
  ).result()
478
482
 
479
483
 
@@ -66,6 +66,7 @@ MIGRATIONS = [
66
66
  """
67
67
  CREATE INDEX CONCURRENTLY IF NOT EXISTS checkpoint_writes_thread_id_idx ON checkpoint_writes(thread_id);
68
68
  """,
69
+ """ALTER TABLE checkpoint_writes ADD COLUMN task_path TEXT NOT NULL DEFAULT '';""",
69
70
  ]
70
71
 
71
72
  SELECT_SQL = f"""
@@ -94,7 +95,7 @@ select
94
95
  and cw.checkpoint_id = checkpoints.checkpoint_id
95
96
  ) as pending_writes,
96
97
  (
97
- select array_agg(array[cw.type::bytea, cw.blob] order by cw.task_id, cw.idx)
98
+ select array_agg(array[cw.type::bytea, cw.blob] order by cw.task_path, cw.task_id, cw.idx)
98
99
  from checkpoint_writes cw
99
100
  where cw.thread_id = checkpoints.thread_id
100
101
  and cw.checkpoint_ns = checkpoints.checkpoint_ns
@@ -119,8 +120,8 @@ UPSERT_CHECKPOINTS_SQL = """
119
120
  """
120
121
 
121
122
  UPSERT_CHECKPOINT_WRITES_SQL = """
122
- INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
123
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
123
+ INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, task_path, idx, channel, type, blob)
124
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
124
125
  ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO UPDATE SET
125
126
  channel = EXCLUDED.channel,
126
127
  type = EXCLUDED.type,
@@ -128,8 +129,8 @@ UPSERT_CHECKPOINT_WRITES_SQL = """
128
129
  """
129
130
 
130
131
  INSERT_CHECKPOINT_WRITES_SQL = """
131
- INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
132
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
132
+ INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, task_path, idx, channel, type, blob)
133
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
133
134
  ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO NOTHING
134
135
  """
135
136
 
@@ -220,14 +221,16 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
220
221
  checkpoint_ns: str,
221
222
  checkpoint_id: str,
222
223
  task_id: str,
224
+ task_path: str,
223
225
  writes: Sequence[tuple[str, Any]],
224
- ) -> list[tuple[str, str, str, str, int, str, str, bytes]]:
226
+ ) -> list[tuple[str, str, str, str, str, int, str, str, bytes]]:
225
227
  return [
226
228
  (
227
229
  thread_id,
228
230
  checkpoint_ns,
229
231
  checkpoint_id,
230
232
  task_id,
233
+ task_path,
231
234
  WRITES_IDX_MAP.get(channel, idx),
232
235
  channel,
233
236
  *self.serde.dumps_typed(value),
@@ -74,6 +74,9 @@ MIGRATIONS = [
74
74
  """
75
75
  CREATE INDEX CONCURRENTLY IF NOT EXISTS checkpoint_writes_thread_id_idx ON checkpoint_writes(thread_id);
76
76
  """,
77
+ """
78
+ ALTER TABLE checkpoint_writes ADD COLUMN task_path TEXT NOT NULL DEFAULT '';
79
+ """,
77
80
  ]
78
81
 
79
82
  SELECT_SQL = f"""
@@ -99,7 +102,7 @@ select
99
102
  and cw.checkpoint_id = (checkpoint->>'id')
100
103
  ) as pending_writes,
101
104
  (
102
- select array_agg(array[cw.type::bytea, cw.blob] order by cw.task_id, cw.idx)
105
+ select array_agg(array[cw.type::bytea, cw.blob] order by cw.task_path, cw.task_id, cw.idx)
103
106
  from checkpoint_writes cw
104
107
  where cw.thread_id = checkpoints.thread_id
105
108
  and cw.checkpoint_ns = checkpoints.checkpoint_ns
@@ -125,8 +128,8 @@ UPSERT_CHECKPOINTS_SQL = """
125
128
  """
126
129
 
127
130
  UPSERT_CHECKPOINT_WRITES_SQL = """
128
- INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
129
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
131
+ INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, task_path, idx, channel, type, blob)
132
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
130
133
  ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO UPDATE SET
131
134
  channel = EXCLUDED.channel,
132
135
  type = EXCLUDED.type,
@@ -134,8 +137,8 @@ UPSERT_CHECKPOINT_WRITES_SQL = """
134
137
  """
135
138
 
136
139
  INSERT_CHECKPOINT_WRITES_SQL = """
137
- INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, blob)
138
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
140
+ INSERT INTO checkpoint_writes (thread_id, checkpoint_ns, checkpoint_id, task_id, task_path, idx, channel, type, blob)
141
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
139
142
  ON CONFLICT (thread_id, checkpoint_ns, checkpoint_id, task_id, idx) DO NOTHING
140
143
  """
141
144
 
@@ -430,6 +433,7 @@ class ShallowPostgresSaver(BasePostgresSaver):
430
433
  config: RunnableConfig,
431
434
  writes: Sequence[tuple[str, Any]],
432
435
  task_id: str,
436
+ task_path: str = "",
433
437
  ) -> None:
434
438
  """Store intermediate writes linked to a checkpoint.
435
439
 
@@ -453,6 +457,7 @@ class ShallowPostgresSaver(BasePostgresSaver):
453
457
  config["configurable"]["checkpoint_ns"],
454
458
  config["configurable"]["checkpoint_id"],
455
459
  task_id,
460
+ task_path,
456
461
  writes,
457
462
  ),
458
463
  )
@@ -747,6 +752,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver):
747
752
  config: RunnableConfig,
748
753
  writes: Sequence[tuple[str, Any]],
749
754
  task_id: str,
755
+ task_path: str = "",
750
756
  ) -> None:
751
757
  """Store intermediate writes linked to a checkpoint asynchronously.
752
758
 
@@ -768,6 +774,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver):
768
774
  config["configurable"]["checkpoint_ns"],
769
775
  config["configurable"]["checkpoint_id"],
770
776
  task_id,
777
+ task_path,
771
778
  writes,
772
779
  )
773
780
  async with self._cursor(pipeline=True) as cur:
@@ -903,6 +910,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver):
903
910
  config: RunnableConfig,
904
911
  writes: Sequence[tuple[str, Any]],
905
912
  task_id: str,
913
+ task_path: str = "",
906
914
  ) -> None:
907
915
  """Store intermediate writes linked to a checkpoint.
908
916
 
@@ -912,7 +920,8 @@ class AsyncShallowPostgresSaver(BasePostgresSaver):
912
920
  config (RunnableConfig): Configuration of the related checkpoint.
913
921
  writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair.
914
922
  task_id (str): Identifier for the task creating the writes.
923
+ task_path (str): Path of the task creating the writes.
915
924
  """
916
925
  return asyncio.run_coroutine_threadsafe(
917
- self.aput_writes(config, writes, task_id), self.loop
926
+ self.aput_writes(config, writes, task_id, task_path), self.loop
918
927
  ).result()
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langgraph-checkpoint-postgres"
3
- version = "2.0.11"
3
+ version = "2.0.12"
4
4
  description = "Library with a Postgres implementation of LangGraph checkpoint saver."
5
5
  authors = []
6
6
  license = "MIT"
@@ -10,7 +10,7 @@ packages = [{ include = "langgraph" }]
10
10
 
11
11
  [tool.poetry.dependencies]
12
12
  python = "^3.9.0,<4.0"
13
- langgraph-checkpoint = "^2.0.7"
13
+ langgraph-checkpoint = "^2.0.10"
14
14
  orjson = ">=3.10.1"
15
15
  psycopg = "^3.2.0"
16
16
  psycopg-pool = "^3.2.0"