manikumargouni commited on
Commit
118ed7e
·
verified ·
1 Parent(s): b10eaa9

Upload config.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. config.py +11 -0
config.py CHANGED
@@ -110,6 +110,11 @@ def _hf_revision() -> str | None:
110
  return rev or None
111
 
112
 
 
 
 
 
 
113
  @lru_cache(maxsize=8)
114
  def _resolve_repo_subdir(local_dir: Path, repo_subdir: str) -> Path:
115
  """Resolve artifact/model subdirs for local dev and HF trust_remote_code.
@@ -120,6 +125,12 @@ def _resolve_repo_subdir(local_dir: Path, repo_subdir: str) -> Path:
120
  if local_dir.exists():
121
  return local_dir
122
 
 
 
 
 
 
 
123
  try:
124
  from huggingface_hub import snapshot_download
125
  except Exception:
 
110
  return rev or None
111
 
112
 
113
+ def _is_hf_dynamic_module_runtime() -> bool:
114
+ """True when executing from HF `trust_remote_code` dynamic module cache."""
115
+ return "transformers_modules" in str(BASE_DIR)
116
+
117
+
118
  @lru_cache(maxsize=8)
119
  def _resolve_repo_subdir(local_dir: Path, repo_subdir: str) -> Path:
120
  """Resolve artifact/model subdirs for local dev and HF trust_remote_code.
 
125
  if local_dir.exists():
126
  return local_dir
127
 
128
+ # Critical guard: during local/Colab training we should never silently point
129
+ # outputs to a Hub snapshot cache path. Only use Hub fallback when running
130
+ # inside HF dynamic modules (`trust_remote_code` path).
131
+ if not _is_hf_dynamic_module_runtime():
132
+ return local_dir
133
+
134
  try:
135
  from huggingface_hub import snapshot_download
136
  except Exception: