Add support for offline mode with HF_HUB_OFFLINE envvar (#1182)

* Add support for offline mode with HF_HUB_OFFLINE envvar

* Apply styling

* chore: lint

---------

Co-authored-by: Wing Lian <wing.lian@gmail.com>
This commit is contained in:
James Wade
2024-01-24 00:41:47 -05:00
committed by GitHub
parent dc051b861d
commit 71141deb18

View File

@@ -365,6 +365,13 @@ def check_accelerate_default_config():
def check_user_token():
# Skip check if HF_HUB_OFFLINE is set to True
if os.getenv("HF_HUB_OFFLINE") == "1":
LOG.info(
"Skipping HuggingFace token verification because HF_HUB_OFFLINE is set to True. Only local files will be used."
)
return True
# Verify if token is valid
api = HfApi()
try: