| |
| """ |
| Upload PyTorch wheel collection to HuggingFace |
| Usage: HF_TOKEN=your_token python upload_to_hf.py |
| """ |
|
|
| import os |
| from huggingface_hub import HfApi |
|
|
| def upload_to_huggingface(): |
| |
| token = os.getenv("HF_TOKEN") |
| if not token: |
| print("โ Error: HF_TOKEN environment variable not set") |
| print("Usage: HF_TOKEN=your_token python upload_to_hf.py") |
| return False |
| |
| |
| api = HfApi(token=token) |
| |
| |
| repo_id = "RDHub/pytorch_python_310" |
| folder_path = "/media/acleda/DATA/code/ai-engineer/khmer-nlp/pytorch_python_310" |
| |
| print(f"Uploading folder: {folder_path}") |
| print(f"To repository: {repo_id}") |
| print("This may take a while due to large file sizes...") |
| |
| try: |
| |
| api.upload_folder( |
| folder_path=folder_path, |
| repo_id=repo_id, |
| repo_type="model", |
| ) |
| |
| print("โ
Upload completed successfully!") |
| print(f"Repository available at: https://huggingface.co/{repo_id}") |
| |
| except Exception as e: |
| print(f"โ Upload failed: {e}") |
| return False |
| |
| return True |
|
|
| if __name__ == "__main__": |
| success = upload_to_huggingface() |
| if success: |
| print("\n๐ PyTorch wheel collection is now available on HuggingFace!") |
| print("Users can now install with:") |
| print("git clone https://huggingface.co/RDHub/pytorch_python_310") |
| print("cd pytorch_python_310 && pip install lib_wheel/*.whl") |
| else: |
| print("\nโ Upload failed. Please check the error messages above.") |