feat: add HuggingFace mirror support for VM providers (#278)
Add support for HuggingFace mirror (hf-mirror.com) to improve download speeds in regions where huggingface.co access is slow. - Support HF_ENDPOINT environment variable detection - Automatically switch to hf-mirror.com when HF_ENDPOINT is set - Apply to Docker, VMware, and VirtualBox providers - Maintain backward compatibility with default huggingface.co URLs Users can now set HF_ENDPOINT=https://hf-mirror.com to use the mirror.
This commit is contained in:
@@ -57,6 +57,12 @@ def _install_vm(vm_name, vms_dir, downloaded_file_name, original_vm_name="Ubuntu
|
||||
else:
|
||||
raise Exception("Unsupported platform or architecture.")
|
||||
|
||||
# Check for HF_ENDPOINT environment variable and replace domain if set to hf-mirror.com
|
||||
hf_endpoint = os.environ.get('HF_ENDPOINT')
|
||||
if hf_endpoint and 'hf-mirror.com' in hf_endpoint:
|
||||
url = url.replace('huggingface.co', 'hf-mirror.com')
|
||||
logger.info(f"Using HF mirror: {url}")
|
||||
|
||||
# Download the virtual machine image
|
||||
logger.info("Downloading the virtual machine image...")
|
||||
downloaded_size = 0
|
||||
|
||||
Reference in New Issue
Block a user