File tree Expand file tree Collapse file tree 4 files changed +5
-3
lines changed Expand file tree Collapse file tree 4 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -291,3 +291,4 @@ def _as_int(value: Optional[str]) -> Optional[int]:
291
291
292
292
default_xet_cache_path = os .path .join (HF_HOME , "xet" )
293
293
HF_XET_CACHE = os .getenv ("HF_XET_CACHE" , default_xet_cache_path )
294
+ HF_HUB_DISABLE_XET : bool = _is_true (os .environ .get ("HF_HUB_DISABLE_XET" ))
Original file line number Diff line number Diff line change @@ -1718,7 +1718,7 @@ def _download_to_tmp_and_move(
1718
1718
displayed_filename = filename ,
1719
1719
)
1720
1720
else :
1721
- if xet_file_data is not None :
1721
+ if xet_file_data is not None and not constants . HF_HUB_DISABLE_XET :
1722
1722
logger .warning (
1723
1723
"Xet Storage is enabled for this repo, but the 'hf_xet' package is not installed. "
1724
1724
"Falling back to regular HTTP download. "
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ def get_hf_transfer_version() -> str:
155
155
# xet
156
156
def is_xet_available () -> bool :
157
157
# since hf_xet is automatically used if available, allow explicit disabling via environment variable
158
- if constants ._is_true ( os . environ . get ( " HF_HUB_DISABLE_XET" )): # type: ignore
158
+ if constants .HF_HUB_DISABLE_XET :
159
159
return False
160
160
161
161
return is_package_available ("hf_xet" )
Original file line number Diff line number Diff line change @@ -288,5 +288,6 @@ def test_env_var_hf_hub_disable_xet() -> None:
288
288
from huggingface_hub .utils ._runtime import is_xet_available
289
289
290
290
monkeypatch = MonkeyPatch ()
291
- monkeypatch .setenv ("HF_HUB_DISABLE_XET" , "1" )
291
+ monkeypatch .setattr ("huggingface_hub.constants.HF_HUB_DISABLE_XET" , True )
292
+
292
293
assert not is_xet_available ()
You can’t perform that action at this time.
0 commit comments