langgraph-checkpoint-sqlite 2.0.2__tar.gz → 2.0.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langgraph-checkpoint-sqlite
3
- Version: 2.0.2
3
+ Version: 2.0.4
4
4
  Summary: Library with a SQLite implementation of LangGraph checkpoint saver.
5
5
  Home-page: https://www.github.com/langchain-ai/langgraph
6
6
  License: MIT
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Requires-Dist: aiosqlite (>=0.20.0,<0.21.0)
15
- Requires-Dist: langgraph-checkpoint (>=2.0.2,<3.0.0)
15
+ Requires-Dist: langgraph-checkpoint (>=2.0.10,<3.0.0)
16
16
  Project-URL: Repository, https://www.github.com/langchain-ai/langgraph
17
17
  Description-Content-Type: text/markdown
18
18
 
@@ -397,7 +397,17 @@ class SqliteSaver(BaseCheckpointSaver[str]):
397
397
  thread_id = config["configurable"]["thread_id"]
398
398
  checkpoint_ns = config["configurable"]["checkpoint_ns"]
399
399
  type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
400
- serialized_metadata = self.jsonplus_serde.dumps(metadata)
400
+ serialized_metadata = self.jsonplus_serde.dumps(
401
+ {
402
+ **{
403
+ k: v
404
+ for k, v in config["configurable"].items()
405
+ if not k.startswith("__")
406
+ },
407
+ **config.get("metadata", {}),
408
+ **metadata,
409
+ }
410
+ )
401
411
  with self.cursor() as cur:
402
412
  cur.execute(
403
413
  "INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
@@ -424,6 +434,7 @@ class SqliteSaver(BaseCheckpointSaver[str]):
424
434
  config: RunnableConfig,
425
435
  writes: Sequence[Tuple[str, Any]],
426
436
  task_id: str,
437
+ task_path: str = "",
427
438
  ) -> None:
428
439
  """Store intermediate writes linked to a checkpoint.
429
440
 
@@ -433,6 +444,7 @@ class SqliteSaver(BaseCheckpointSaver[str]):
433
444
  config (RunnableConfig): Configuration of the related checkpoint.
434
445
  writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair.
435
446
  task_id (str): Identifier for the task creating the writes.
447
+ task_path (str): Path of the task creating the writes.
436
448
  """
437
449
  query = (
438
450
  "INSERT OR REPLACE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
@@ -1,17 +1,8 @@
1
1
  import asyncio
2
2
  import random
3
+ from collections.abc import AsyncIterator, Iterator, Sequence
3
4
  from contextlib import asynccontextmanager
4
- from typing import (
5
- Any,
6
- AsyncIterator,
7
- Callable,
8
- Dict,
9
- Iterator,
10
- Optional,
11
- Sequence,
12
- Tuple,
13
- TypeVar,
14
- )
5
+ from typing import Any, Callable, Optional, TypeVar
15
6
 
16
7
  import aiosqlite
17
8
  from langchain_core.runnables import RunnableConfig
@@ -173,7 +164,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
173
164
  self,
174
165
  config: Optional[RunnableConfig],
175
166
  *,
176
- filter: Optional[Dict[str, Any]] = None,
167
+ filter: Optional[dict[str, Any]] = None,
177
168
  before: Optional[RunnableConfig] = None,
178
169
  limit: Optional[int] = None,
179
170
  ) -> Iterator[CheckpointTuple]:
@@ -207,7 +198,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
207
198
  while True:
208
199
  try:
209
200
  yield asyncio.run_coroutine_threadsafe(
210
- anext(aiter_),
201
+ anext(aiter_), # noqa: F821
211
202
  self.loop,
212
203
  ).result()
213
204
  except StopAsyncIteration:
@@ -239,10 +230,14 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
239
230
  ).result()
240
231
 
241
232
  def put_writes(
242
- self, config: RunnableConfig, writes: Sequence[Tuple[str, Any]], task_id: str
233
+ self,
234
+ config: RunnableConfig,
235
+ writes: Sequence[tuple[str, Any]],
236
+ task_id: str,
237
+ task_path: str = "",
243
238
  ) -> None:
244
239
  return asyncio.run_coroutine_threadsafe(
245
- self.aput_writes(config, writes, task_id), self.loop
240
+ self.aput_writes(config, writes, task_id, task_path), self.loop
246
241
  ).result()
247
242
 
248
243
  async def setup(self) -> None:
@@ -372,7 +367,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
372
367
  self,
373
368
  config: Optional[RunnableConfig],
374
369
  *,
375
- filter: Optional[Dict[str, Any]] = None,
370
+ filter: Optional[dict[str, Any]] = None,
376
371
  before: Optional[RunnableConfig] = None,
377
372
  limit: Optional[int] = None,
378
373
  ) -> AsyncIterator[CheckpointTuple]:
@@ -398,9 +393,11 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
398
393
  ORDER BY checkpoint_id DESC"""
399
394
  if limit:
400
395
  query += f" LIMIT {limit}"
401
- async with self.lock, self.conn.execute(
402
- query, params
403
- ) as cur, self.conn.cursor() as wcur:
396
+ async with (
397
+ self.lock,
398
+ self.conn.execute(query, params) as cur,
399
+ self.conn.cursor() as wcur,
400
+ ):
404
401
  async for (
405
402
  thread_id,
406
403
  checkpoint_ns,
@@ -466,17 +463,30 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
466
463
  thread_id = config["configurable"]["thread_id"]
467
464
  checkpoint_ns = config["configurable"]["checkpoint_ns"]
468
465
  type_, serialized_checkpoint = self.serde.dumps_typed(checkpoint)
469
- serialized_metadata = self.jsonplus_serde.dumps(metadata)
470
- async with self.lock, self.conn.execute(
471
- "INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
472
- (
473
- str(config["configurable"]["thread_id"]),
474
- checkpoint_ns,
475
- checkpoint["id"],
476
- config["configurable"].get("checkpoint_id"),
477
- type_,
478
- serialized_checkpoint,
479
- serialized_metadata,
466
+ serialized_metadata = self.jsonplus_serde.dumps(
467
+ {
468
+ **{
469
+ k: v
470
+ for k, v in config["configurable"].items()
471
+ if not k.startswith("__")
472
+ },
473
+ **config.get("metadata", {}),
474
+ **metadata,
475
+ }
476
+ )
477
+ async with (
478
+ self.lock,
479
+ self.conn.execute(
480
+ "INSERT OR REPLACE INTO checkpoints (thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id, type, checkpoint, metadata) VALUES (?, ?, ?, ?, ?, ?, ?)",
481
+ (
482
+ str(config["configurable"]["thread_id"]),
483
+ checkpoint_ns,
484
+ checkpoint["id"],
485
+ config["configurable"].get("checkpoint_id"),
486
+ type_,
487
+ serialized_checkpoint,
488
+ serialized_metadata,
489
+ ),
480
490
  ),
481
491
  ):
482
492
  await self.conn.commit()
@@ -491,8 +501,9 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
491
501
  async def aput_writes(
492
502
  self,
493
503
  config: RunnableConfig,
494
- writes: Sequence[Tuple[str, Any]],
504
+ writes: Sequence[tuple[str, Any]],
495
505
  task_id: str,
506
+ task_path: str = "",
496
507
  ) -> None:
497
508
  """Store intermediate writes linked to a checkpoint asynchronously.
498
509
 
@@ -502,6 +513,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]):
502
513
  config (RunnableConfig): Configuration of the related checkpoint.
503
514
  writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair.
504
515
  task_id (str): Identifier for the task creating the writes.
516
+ task_path (str): Path of the task creating the writes.
505
517
  """
506
518
  query = (
507
519
  "INSERT OR REPLACE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langgraph-checkpoint-sqlite"
3
- version = "2.0.2"
3
+ version = "2.0.4"
4
4
  description = "Library with a SQLite 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"
13
- langgraph-checkpoint = "^2.0.2"
13
+ langgraph-checkpoint = "^2.0.10"
14
14
  aiosqlite = "^0.20.0"
15
15
 
16
16
  [tool.poetry.group.dev.dependencies]