mirror of
https://github.com/deepseek-ai/DeepInfer.git
synced 2026-10-28 14:57:09 +08:00
fix: validate boolean environment variables with strict parsing (#218)
This commit is contained in:
parent
9bd9cf243f
commit
553741557a
@ -7,10 +7,17 @@ from datetime import timedelta
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
DEFAULT_PREFILL_MAX_SUM_SEQLEN_K = 2**30
|
DEFAULT_PREFILL_MAX_SUM_SEQLEN_K = 2**30
|
||||||
|
_FALSE = {"0", "", "false"}
|
||||||
|
_TRUE = {"1", "true"}
|
||||||
|
|
||||||
|
|
||||||
def _bool(v: str | None, default: str = "0") -> bool:
|
def _bool(v: str | None, default: str = "0") -> bool:
|
||||||
return (v if v is not None else default) not in ("0", "", "false", "False")
|
value = (v if v is not None else default).lower()
|
||||||
|
if value in _FALSE:
|
||||||
|
return False
|
||||||
|
if value in _TRUE:
|
||||||
|
return True
|
||||||
|
raise ValueError("expected one of '0', '1', 'false', 'true' (case-insensitive)")
|
||||||
|
|
||||||
|
|
||||||
def _int(v: str | None, default: int = 0) -> int:
|
def _int(v: str | None, default: int = 0) -> int:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user