MCPcopy
hub / github.com/HKUDS/LightRAG / validate_runtime_target

Function validate_runtime_target

lightrag/api/runtime_validation.py:82–118  ·  view source on GitHub ↗

Validate `.env` runtime target against the current runtime environment.

(
    runtime_target: str | None,
    runtime_environment: RuntimeEnvironment | None = None,
)

Source from the content-addressed store, hash-verified

80
81
82def validate_runtime_target(
83 runtime_target: str | None,
84 runtime_environment: RuntimeEnvironment | None = None,
85) -> tuple[bool, str | None]:
86 """Validate `.env` runtime target against the current runtime environment."""
87
88 if runtime_target is None:
89 return True, None
90
91 normalized_target = runtime_target.strip().lower()
92 runtime_environment = runtime_environment or detect_runtime_environment()
93
94 if normalized_target == "host":
95 if runtime_environment.in_container:
96 return (
97 False,
98 "Configuration error in .env: LIGHTRAG_RUNTIME_TARGET=host.\n"
99 "This value from .env requires the server process to run on the host, "
100 f"but the current process is running inside {runtime_environment.label}.",
101 )
102 return True, None
103
104 if normalized_target in _CONTAINER_RUNTIME_TARGETS:
105 if runtime_environment.in_container:
106 return True, None
107 return (
108 False,
109 f"Configuration error in .env: LIGHTRAG_RUNTIME_TARGET={runtime_target}.\n"
110 "This value from .env requires the server process to run inside Docker or "
111 "Kubernetes, but the current process is running on the host.",
112 )
113
114 return (
115 False,
116 f"Configuration error in .env: LIGHTRAG_RUNTIME_TARGET={runtime_target!r}.\n"
117 "This value from .env must be 'host' or 'compose' (alias: 'docker').",
118 )
119
120
121def validate_runtime_target_from_env_file(

Calls 1