sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
@@ -0,0 +1,54 @@
|
||||
"""Runtime checks shared by the controller's interpreter probe and workers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
|
||||
|
||||
def storage_backend(config) -> str:
|
||||
"""Return the effective LangGraph persistence adapter selected by config."""
|
||||
checkpoint = getattr(config, "checkpointer", None)
|
||||
if checkpoint is not None:
|
||||
if checkpoint.type == "postgres":
|
||||
from deerflow.runtime.checkpointer.async_provider import _use_postgres_enabled
|
||||
|
||||
return "postgres" if _use_postgres_enabled(checkpoint) else "sqlite"
|
||||
if checkpoint.type == "sqlite":
|
||||
return "sqlite"
|
||||
return "memory"
|
||||
|
||||
database = getattr(config, "database", None)
|
||||
backend = getattr(database, "backend", "memory")
|
||||
return backend if backend in {"postgres", "sqlite"} else "memory"
|
||||
|
||||
|
||||
def verify_storage_dependencies(config) -> str:
|
||||
"""Verify the adapters the configured runtime will import, without DB access."""
|
||||
backend = storage_backend(config)
|
||||
modules = {
|
||||
"postgres": (
|
||||
"langgraph.checkpoint.postgres.aio",
|
||||
"langgraph.store.postgres.aio",
|
||||
"psycopg.rows",
|
||||
"psycopg_pool",
|
||||
),
|
||||
"sqlite": (
|
||||
"langgraph.checkpoint.sqlite.aio",
|
||||
"langgraph.store.sqlite.aio",
|
||||
),
|
||||
}.get(backend, ())
|
||||
for module in modules:
|
||||
try:
|
||||
importlib.import_module(module)
|
||||
except ImportError as exc:
|
||||
install = (
|
||||
"langgraph-checkpoint-postgres psycopg[binary] psycopg-pool"
|
||||
if backend == "postgres"
|
||||
else "langgraph-checkpoint-sqlite aiosqlite"
|
||||
)
|
||||
raise RuntimeError(
|
||||
f"Worker Python is missing {module} required by the configured "
|
||||
f"{backend} chat store; install {install} in the main service "
|
||||
"runtime and ensure Workers use that same Python environment"
|
||||
) from exc
|
||||
return backend
|
||||
Reference in new issue
Block a user