langgraph-runtime-pg 0.11.1__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.
- langgraph_runtime_pg-0.11.1/.gitignore +15 -0
- langgraph_runtime_pg-0.11.1/LICENSE +21 -0
- langgraph_runtime_pg-0.11.1/PKG-INFO +47 -0
- langgraph_runtime_pg-0.11.1/README.md +7 -0
- langgraph_runtime_pg-0.11.1/pyproject.toml +84 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/__init__.py +38 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/checkpoint.py +83 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/database.py +480 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/lifespan.py +198 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/metrics.py +7 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrate.py +101 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrations/__init__.py +1 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrations/env.py +51 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrations/script.py.mako +27 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrations/versions/001_initial_schema.py +331 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/migrations/versions/__init__.py +1 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/models.py +196 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/ops.py +3538 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/queue.py +270 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/redis_stream.py +894 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/retry.py +39 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/routes.py +9 -0
- langgraph_runtime_pg-0.11.1/src/langgraph_runtime_pg/store.py +183 -0
- langgraph_runtime_pg-0.11.1/tests/conftest.py +183 -0
- langgraph_runtime_pg-0.11.1/tests/test_e2e.py +250 -0
- langgraph_runtime_pg-0.11.1/tests/test_interface.py +316 -0
- langgraph_runtime_pg-0.11.1/tests/test_ops_eager_iterators.py +249 -0
- langgraph_runtime_pg-0.11.1/tests/test_queue.py +699 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohankumar Ramachandran
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: langgraph-runtime-pg
|
|
3
|
+
Version: 0.11.1
|
|
4
|
+
Summary: Self-hosted LangSmith Deployments alternative: MIT Postgres+Redis runtime (edition=pg) for stock langgraph-api
|
|
5
|
+
Project-URL: Homepage, https://github.com/langhost/langhost
|
|
6
|
+
Project-URL: Repository, https://github.com/langhost/langhost
|
|
7
|
+
Project-URL: Issues, https://github.com/langhost/langhost/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/langhost/langhost/releases
|
|
9
|
+
Author-email: Mohankumar Ramachandran <mail@mohanram.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent-protocol,agent-server,agents,ai-agents,asgi,checkpoint,langchain,langgraph,langgraph-api,langgraph-checkpoint,langgraph-sdk,langsmith,langsmith-deployments,llm,multi-agent,open-source,postgres,postgresql,redis,runtime,self-hosted,uvicorn
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Database
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.11
|
|
28
|
+
Requires-Dist: alembic>=1.14
|
|
29
|
+
Requires-Dist: asyncpg>=0.29
|
|
30
|
+
Requires-Dist: croniter>=1.0
|
|
31
|
+
Requires-Dist: langgraph-api==0.11.1
|
|
32
|
+
Requires-Dist: langgraph-checkpoint-postgres==3.1.0
|
|
33
|
+
Requires-Dist: orjson>=3.9
|
|
34
|
+
Requires-Dist: psycopg[binary]>=3.3.4
|
|
35
|
+
Requires-Dist: redis>=5.0
|
|
36
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.0.51
|
|
37
|
+
Requires-Dist: starlette>=0.37
|
|
38
|
+
Requires-Dist: structlog>=24.0
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# langgraph-runtime-pg
|
|
42
|
+
|
|
43
|
+
MIT Postgres + Redis runtime (`LANGGRAPH_RUNTIME_EDITION=pg`) for stock
|
|
44
|
+
[`langgraph-api`](https://pypi.org/project/langgraph-api/).
|
|
45
|
+
|
|
46
|
+
See the [repository README](https://github.com/langhost/langhost)
|
|
47
|
+
for setup, CLI (`langhost`), and architecture.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# langgraph-runtime-pg
|
|
2
|
+
|
|
3
|
+
MIT Postgres + Redis runtime (`LANGGRAPH_RUNTIME_EDITION=pg`) for stock
|
|
4
|
+
[`langgraph-api`](https://pypi.org/project/langgraph-api/).
|
|
5
|
+
|
|
6
|
+
See the [repository README](https://github.com/langhost/langhost)
|
|
7
|
+
for setup, CLI (`langhost`), and architecture.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "langgraph-runtime-pg"
|
|
3
|
+
# Tracks langgraph-api: X.Y.Z or X.Y.Z.postN for our patches on the same API.
|
|
4
|
+
version = "0.11.1"
|
|
5
|
+
description = "Self-hosted LangSmith Deployments alternative: MIT Postgres+Redis runtime (edition=pg) for stock langgraph-api"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
authors = [{ name = "Mohankumar Ramachandran", email = "mail@mohanram.dev" }]
|
|
11
|
+
keywords = [
|
|
12
|
+
"langgraph",
|
|
13
|
+
"langsmith",
|
|
14
|
+
"langsmith-deployments",
|
|
15
|
+
"langchain",
|
|
16
|
+
"langgraph-api",
|
|
17
|
+
"langgraph-sdk",
|
|
18
|
+
"langgraph-checkpoint",
|
|
19
|
+
"agent-server",
|
|
20
|
+
"agent-protocol",
|
|
21
|
+
"ai-agents",
|
|
22
|
+
"agents",
|
|
23
|
+
"multi-agent",
|
|
24
|
+
"llm",
|
|
25
|
+
"self-hosted",
|
|
26
|
+
"open-source",
|
|
27
|
+
"postgres",
|
|
28
|
+
"postgresql",
|
|
29
|
+
"redis",
|
|
30
|
+
"checkpoint",
|
|
31
|
+
"runtime",
|
|
32
|
+
"uvicorn",
|
|
33
|
+
"asgi",
|
|
34
|
+
]
|
|
35
|
+
classifiers = [
|
|
36
|
+
"Development Status :: 4 - Beta",
|
|
37
|
+
"Intended Audience :: Developers",
|
|
38
|
+
"License :: OSI Approved :: MIT License",
|
|
39
|
+
"Operating System :: OS Independent",
|
|
40
|
+
"Programming Language :: Python",
|
|
41
|
+
"Programming Language :: Python :: 3",
|
|
42
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
43
|
+
"Programming Language :: Python :: 3.11",
|
|
44
|
+
"Programming Language :: Python :: 3.12",
|
|
45
|
+
"Programming Language :: Python :: 3.13",
|
|
46
|
+
"Topic :: Database",
|
|
47
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
48
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
49
|
+
"Typing :: Typed",
|
|
50
|
+
]
|
|
51
|
+
dependencies = [
|
|
52
|
+
"sqlalchemy[asyncio]>=2.0.51",
|
|
53
|
+
"asyncpg>=0.29",
|
|
54
|
+
"redis>=5.0",
|
|
55
|
+
"alembic>=1.14",
|
|
56
|
+
"psycopg[binary]>=3.3.4",
|
|
57
|
+
"structlog>=24.0",
|
|
58
|
+
"croniter>=1.0",
|
|
59
|
+
"orjson>=3.9",
|
|
60
|
+
"starlette>=0.37",
|
|
61
|
+
# Exact Agent Server this runtime edition targets (version sync enforced in CI).
|
|
62
|
+
"langgraph-api==0.11.1",
|
|
63
|
+
"langgraph-checkpoint-postgres==3.1.0",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[project.urls]
|
|
67
|
+
Homepage = "https://github.com/langhost/langhost"
|
|
68
|
+
Repository = "https://github.com/langhost/langhost"
|
|
69
|
+
Issues = "https://github.com/langhost/langhost/issues"
|
|
70
|
+
Changelog = "https://github.com/langhost/langhost/releases"
|
|
71
|
+
|
|
72
|
+
[project.scripts]
|
|
73
|
+
langgraph-runtime-pg-migrate = "langgraph_runtime_pg.migrate:main"
|
|
74
|
+
|
|
75
|
+
[build-system]
|
|
76
|
+
requires = ["hatchling"]
|
|
77
|
+
build-backend = "hatchling.build"
|
|
78
|
+
|
|
79
|
+
[tool.hatch.build.targets.wheel]
|
|
80
|
+
packages = ["src/langgraph_runtime_pg"]
|
|
81
|
+
|
|
82
|
+
# Keep Alembic templates / non-.py migration assets in the wheel.
|
|
83
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
84
|
+
"src/langgraph_runtime_pg/migrations/script.py.mako" = "langgraph_runtime_pg/migrations/script.py.mako"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Postgres+Redis LangGraph runtime (LANGGRAPH_RUNTIME_EDITION=pg)."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
from langgraph_runtime_pg import (
|
|
6
|
+
checkpoint,
|
|
7
|
+
database,
|
|
8
|
+
lifespan,
|
|
9
|
+
metrics,
|
|
10
|
+
migrate,
|
|
11
|
+
models,
|
|
12
|
+
ops,
|
|
13
|
+
queue,
|
|
14
|
+
redis_stream,
|
|
15
|
+
retry,
|
|
16
|
+
routes,
|
|
17
|
+
store,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
__version__ = version("langgraph-runtime-pg")
|
|
22
|
+
except PackageNotFoundError: # pragma: no cover - editable / source tree edge
|
|
23
|
+
__version__ = "0.0.0"
|
|
24
|
+
__all__ = [
|
|
25
|
+
"__version__",
|
|
26
|
+
"checkpoint",
|
|
27
|
+
"database",
|
|
28
|
+
"lifespan",
|
|
29
|
+
"metrics",
|
|
30
|
+
"migrate",
|
|
31
|
+
"models",
|
|
32
|
+
"ops",
|
|
33
|
+
"queue",
|
|
34
|
+
"redis_stream",
|
|
35
|
+
"retry",
|
|
36
|
+
"routes",
|
|
37
|
+
"store",
|
|
38
|
+
]
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Checkpointer factory wrapping langgraph-checkpoint-postgres."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
from typing import Any, cast
|
|
7
|
+
|
|
8
|
+
from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver
|
|
9
|
+
from psycopg.rows import dict_row
|
|
10
|
+
from psycopg_pool import AsyncConnectionPool
|
|
11
|
+
|
|
12
|
+
from langgraph_runtime_pg.database import to_psycopg_uri
|
|
13
|
+
|
|
14
|
+
_POOL: AsyncConnectionPool[Any] | None = None
|
|
15
|
+
_CHECKPOINTER: AsyncPostgresSaver | None = None
|
|
16
|
+
_SETUP_LOCK = asyncio.Lock()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def setup_checkpointer() -> AsyncPostgresSaver:
|
|
20
|
+
"""Open a psycopg pool and initialize AsyncPostgresSaver tables."""
|
|
21
|
+
global _POOL, _CHECKPOINTER
|
|
22
|
+
async with _SETUP_LOCK:
|
|
23
|
+
if _CHECKPOINTER is not None:
|
|
24
|
+
return _CHECKPOINTER
|
|
25
|
+
if _POOL is not None:
|
|
26
|
+
try:
|
|
27
|
+
await _POOL.close()
|
|
28
|
+
except Exception:
|
|
29
|
+
pass
|
|
30
|
+
_POOL = None
|
|
31
|
+
|
|
32
|
+
uri = to_psycopg_uri()
|
|
33
|
+
# autocommit required: setup() runs CREATE INDEX CONCURRENTLY
|
|
34
|
+
pool = AsyncConnectionPool(
|
|
35
|
+
conninfo=uri,
|
|
36
|
+
min_size=1,
|
|
37
|
+
max_size=10,
|
|
38
|
+
open=False,
|
|
39
|
+
kwargs={
|
|
40
|
+
"autocommit": True,
|
|
41
|
+
"prepare_threshold": 0,
|
|
42
|
+
"row_factory": dict_row,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
try:
|
|
46
|
+
await pool.open()
|
|
47
|
+
saver = AsyncPostgresSaver(cast(Any, pool))
|
|
48
|
+
await saver.setup()
|
|
49
|
+
except Exception:
|
|
50
|
+
try:
|
|
51
|
+
await pool.close()
|
|
52
|
+
except Exception:
|
|
53
|
+
pass
|
|
54
|
+
raise
|
|
55
|
+
_POOL = pool
|
|
56
|
+
_CHECKPOINTER = saver
|
|
57
|
+
return _CHECKPOINTER
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def teardown_checkpointer() -> None:
|
|
61
|
+
"""Close the checkpointer pool."""
|
|
62
|
+
global _POOL, _CHECKPOINTER
|
|
63
|
+
_CHECKPOINTER = None
|
|
64
|
+
pool = _POOL
|
|
65
|
+
_POOL = None
|
|
66
|
+
if pool is not None:
|
|
67
|
+
try:
|
|
68
|
+
await pool.close()
|
|
69
|
+
except Exception:
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def Checkpointer(*args: Any, unpack_hook: Any = None, **kwargs: Any) -> AsyncPostgresSaver:
|
|
74
|
+
"""Return the process-wide AsyncPostgresSaver (requires setup_checkpointer)."""
|
|
75
|
+
if _CHECKPOINTER is None:
|
|
76
|
+
raise RuntimeError(
|
|
77
|
+
"Checkpointer not initialized; call start_pool()/setup_checkpointer() first "
|
|
78
|
+
"(DATABASE_URI required)"
|
|
79
|
+
)
|
|
80
|
+
return _CHECKPOINTER
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
__all__ = ["Checkpointer", "setup_checkpointer", "teardown_checkpointer"]
|