langgraph-runtime-inmem 0.36.0.dev6__py3-none-any.whl → 0.36.0.dev7__py3-none-any.whl

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.
@@ -10,7 +10,7 @@ from langgraph_runtime_inmem import (
10
10
  store,
11
11
  )
12
12
 
13
- __version__ = "0.36.0.dev6"
13
+ __version__ = "0.36.0.dev7"
14
14
  __all__ = [
15
15
  "ops",
16
16
  "database",
@@ -299,3 +299,50 @@ def Checkpointer(*args, unpack_hook=None, **kwargs):
299
299
 
300
300
 
301
301
  __all__ = ["Checkpointer"]
302
+
303
+
304
+ def _nbytes(value: Any) -> int:
305
+ if isinstance(value, bytes | bytearray | memoryview):
306
+ return len(value)
307
+ if isinstance(value, tuple | list):
308
+ return sum(_nbytes(item) for item in value)
309
+ return 0
310
+
311
+
312
+ async def thread_storage(conn: Any, thread_id: str) -> dict[str, Any]:
313
+ """Bytes a thread's checkpoints occupy in memory, per table and per channel.
314
+
315
+ Same shape as the postgres runtime's report, so one endpoint serves both.
316
+ """
317
+ saver = Checkpointer()
318
+ by_channel: dict[str, dict[str, int]] = {}
319
+ for (tid, _ns, channel, _version), blob in list(saver.blobs.items()):
320
+ if tid != thread_id:
321
+ continue
322
+ entry = by_channel.setdefault(channel, {"versions": 0, "bytes": 0})
323
+ entry["versions"] += 1
324
+ entry["bytes"] += _nbytes(blob)
325
+ checkpoint_count = checkpoint_bytes = 0
326
+ if thread_id in saver.storage:
327
+ for checkpoints in saver.storage[thread_id].values():
328
+ for stored in checkpoints.values():
329
+ checkpoint_count += 1
330
+ checkpoint_bytes += _nbytes(stored)
331
+ write_count = write_bytes = 0
332
+ for (tid, _ns, _checkpoint_id), writes in list(saver.writes.items()):
333
+ if tid != thread_id:
334
+ continue
335
+ for write in writes.values():
336
+ write_count += 1
337
+ write_bytes += _nbytes(write)
338
+ channel_bytes = sum(entry["bytes"] for entry in by_channel.values())
339
+ return {
340
+ "total_bytes": checkpoint_bytes + channel_bytes + write_bytes,
341
+ "checkpoints": {"count": checkpoint_count, "bytes": checkpoint_bytes},
342
+ "channel_values": {
343
+ "count": sum(entry["versions"] for entry in by_channel.values()),
344
+ "bytes": channel_bytes,
345
+ "by_channel": by_channel,
346
+ },
347
+ "pending_writes": {"count": write_count, "bytes": write_bytes},
348
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-runtime-inmem
3
- Version: 0.36.0.dev6
3
+ Version: 0.36.0.dev7
4
4
  Summary: Inmem implementation for the LangGraph API server.
5
5
  Author-email: Will Fu-Hinthorn <will@langchain.dev>
6
6
  License: Elastic-2.0
@@ -1,6 +1,6 @@
1
- langgraph_runtime_inmem/__init__.py,sha256=M6VflFHbXEgvO81PfF83fzpAfAihXRl6PsaNTu0_dBw,342
1
+ langgraph_runtime_inmem/__init__.py,sha256=Nbur-y5GQywaBa_M7pVAY7kDOVBl7kMyL_2b9uMlqRk,342
2
2
  langgraph_runtime_inmem/_persistence.py,sha256=0h_HLXc079TG0rXoiQjICPZLhhBpTsmZ2PG8UbB5YY4,1879
3
- langgraph_runtime_inmem/checkpoint.py,sha256=YWypCmwCkuG3vbgKh36Snurgig5vXyjeL0cOOfh-hkM,10313
3
+ langgraph_runtime_inmem/checkpoint.py,sha256=oC8MILNJVmrv3Ph2XyRJ49Wb883yuv2tlsOCuPDRin0,12173
4
4
  langgraph_runtime_inmem/database.py,sha256=BdEPPBn2N-g5GsqWcia96SrHLKqocXRMYAO6pHlGcHM,6779
5
5
  langgraph_runtime_inmem/inmem_stream.py,sha256=ZKwPFtSFcQfdDLSIkEBpUXv692YdPpzpcqy5wzJjcUY,9207
6
6
  langgraph_runtime_inmem/lifespan.py,sha256=F93NL8ckeJGe78WhNMeC0ysOchSBym69KwyHIa_yqkY,6736
@@ -10,6 +10,6 @@ langgraph_runtime_inmem/queue.py,sha256=CtsVVtxj3-QQ2OeXia2CcasNGLov02kfg0q0yQMy
10
10
  langgraph_runtime_inmem/retry.py,sha256=XmldOP4e_H5s264CagJRVnQMDFcEJR_dldVR1Hm5XvM,763
11
11
  langgraph_runtime_inmem/routes.py,sha256=QtG9KPForGQHwMZYzl3BRV4Zy1pt0zJxPCX2hO0gaqY,18693
12
12
  langgraph_runtime_inmem/store.py,sha256=7hZnVHp097RYAen7SmTQSl-9tiiDCQfLehVxzxU2xAo,3811
13
- langgraph_runtime_inmem-0.36.0.dev6.dist-info/METADATA,sha256=k24YgOxlogp3M8l8bE4q1WidBDR5noc6_duPmuwNJAw,607
14
- langgraph_runtime_inmem-0.36.0.dev6.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
15
- langgraph_runtime_inmem-0.36.0.dev6.dist-info/RECORD,,
13
+ langgraph_runtime_inmem-0.36.0.dev7.dist-info/METADATA,sha256=883jlRlsJoTng30krA-uY9Ls-0ZLgVcJiB9U4rggbcY,607
14
+ langgraph_runtime_inmem-0.36.0.dev7.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
15
+ langgraph_runtime_inmem-0.36.0.dev7.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.0
2
+ Generator: hatchling 1.32.4
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any