fix: strip empty env vars in _getenv_num/_getenv_bool; unify FORCE_CPU
- _getenv_num: add raw.strip() + empty-string guard so numeric vars set to "" (common Compose pattern for "use default") return the default silently instead of warning "not a valid int/float" - _getenv_bool: same guard so True-defaulted flags set to "" return the configured default instead of silently returning False - embeddings.py: replace inline FORCE_CPU bool parse with _getenv_bool
This commit is contained in:
@@ -16,6 +16,9 @@ def _getenv_num(name: str, default, cast):
|
||||
raw = os.getenv(name)
|
||||
if raw is None:
|
||||
return default
|
||||
raw = raw.strip()
|
||||
if not raw:
|
||||
return default
|
||||
try:
|
||||
return cast(raw)
|
||||
except ValueError:
|
||||
@@ -46,6 +49,9 @@ def _getenv_bool(name: str, default: bool) -> bool:
|
||||
raw = os.getenv(name)
|
||||
if raw is None:
|
||||
return default
|
||||
raw = raw.strip()
|
||||
if not raw:
|
||||
return default
|
||||
return raw.lower() in ("true", "1", "yes")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user