fix: support huggingface-cli login for community cache uploads

Fall back to huggingface_hub stored token so users who ran
'huggingface-cli login' can upload without setting HF_TOKEN manually.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ethanfel
2026-04-04 14:02:49 +02:00
co-authored by Claude Sonnet 4.6
parent b323d810a3
commit 3146aff22e
+8 -1
View File
@@ -9345,7 +9345,14 @@ class LoRAAutoTuner(LoRAOptimizer):
and len(content_hashes) == len(active_loras)):
_hf_token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGING_FACE_HUB_TOKEN")
if not _hf_token:
logging.warning("[AutoTuner Community] HF_TOKEN not set, skipping upload")
try:
from huggingface_hub import get_token as _hf_get_token
_hf_token = _hf_get_token()
except Exception:
pass
if not _hf_token:
logging.warning("[AutoTuner Community] No HF token found. "
"Run 'huggingface-cli login' or set HF_TOKEN to enable uploads.")
else:
self._community_upload_results(
new_lora_entries, new_pair_entries,