mattbitzesty commited on
Commit
f516cb0
·
unverified ·
1 Parent(s): 612854b

fix: monkey-patch is_xet_available to force legacy LFS upload in HF job

Browse files
Files changed (1) hide show
  1. scripts/hf_train_job.py +9 -20
scripts/hf_train_job.py CHANGED
@@ -16,6 +16,7 @@ TOKEN = os.environ.get("HF_TOKEN")
16
  # Disable Xet to avoid a hf_xet/huggingface_hub progress-reporter bug that
17
  # crashes large-file uploads in the HF Jobs image.
18
  os.environ["HF_HUB_ENABLE_XET"] = "0"
 
19
 
20
  WORKSPACE = Path("/workspace")
21
  SOURCE_DIR = WORKSPACE / "pino-fresh"
@@ -193,29 +194,17 @@ if TOKEN and checkpoint_path and Path(checkpoint_path).exists():
193
  # Monkey-patch / bypass Xet to avoid a hf_xet/huggingface_hub bug that
194
  # crashes large-file uploads in the HF Jobs image.
195
  try:
196
- import huggingface_hub
197
 
198
- # Force the library to believe Xet is unavailable.
199
- huggingface_hub.utils._xet_cache = None
200
- huggingface_hub.utils._xet_initialized = False
201
- _log("[HF-JOB] Forced Xet cache off and set _xet_initialized=False")
202
- except Exception as patch_exc:
203
- _log(f"[HF-JOB] Could not disable Xet: {patch_exc}")
204
 
205
- try:
206
- from huggingface_hub.utils import _xet_progress_reporting as _xpr
207
- _xpr.XetProgressReporter.update_progress = lambda self, *args, **kwargs: None
208
- _xpr.XetProgressReporter.close = lambda self, *args, **kwargs: None
209
- except Exception:
210
- pass
211
 
212
- try:
213
- import huggingface_hub._commit_api as _ca
214
- _ca._upload_xet_files = lambda *args, **kwargs: None
215
- except Exception:
216
- pass
217
-
218
- _log("[HF-JOB] Xet bypass complete")
219
 
220
  from huggingface_hub import HfApi, create_repo
221
 
 
16
  # Disable Xet to avoid a hf_xet/huggingface_hub progress-reporter bug that
17
  # crashes large-file uploads in the HF Jobs image.
18
  os.environ["HF_HUB_ENABLE_XET"] = "0"
19
+ os.environ["HF_HUB_DISABLE_XET"] = "1"
20
 
21
  WORKSPACE = Path("/workspace")
22
  SOURCE_DIR = WORKSPACE / "pino-fresh"
 
194
  # Monkey-patch / bypass Xet to avoid a hf_xet/huggingface_hub bug that
195
  # crashes large-file uploads in the HF Jobs image.
196
  try:
197
+ import huggingface_hub.utils._runtime as _runtime
198
 
199
+ _orig_is_xet_available = _runtime.is_xet_available
 
 
 
 
 
200
 
201
+ def _force_disable_xet():
202
+ return False
 
 
 
 
203
 
204
+ _runtime.is_xet_available = _force_disable_xet
205
+ _log("[HF-JOB] Forced is_xet_available() to False")
206
+ except Exception as patch_exc:
207
+ _log(f"[HF-JOB] Could not disable xet availability: {patch_exc}")
 
 
 
208
 
209
  from huggingface_hub import HfApi, create_repo
210