Spaces:
Running
Running
File size: 682 Bytes
3865888 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | """Offline enforcement (V6 phase_28): FLYBRAIN_OFFLINE=1 propagates to every
library that might phone home (HF hub, transformers, datasets, telemetry).
Call apply_offline_env() at process startup (server, tests, scripts).
"""
import os
OFFLINE_VARS = {
"HF_HUB_OFFLINE": "1",
"TRANSFORMERS_OFFLINE": "1",
"HF_DATASETS_OFFLINE": "1",
"DISABLE_TELEMETRY": "1",
"DO_NOT_TRACK": "1",
}
def is_offline() -> bool:
return os.environ.get("FLYBRAIN_OFFLINE", "0") == "1"
def apply_offline_env() -> bool:
if not is_offline():
return False
for k, v in OFFLINE_VARS.items():
os.environ.setdefault(k, v)
return True
apply_offline_env()
|