llm-gguf-tools/helpers/huggingface/wrapper.py
2025-08-09 17:16:02 +01:00

57 lines
1.9 KiB
Python

"""Compatibility wrapper for HuggingFace operations.
Provides a compatible interface matching the old HuggingFaceUploader
class for backward compatibility during refactoring.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
from helpers.huggingface.client import HuggingFaceClient
from helpers.huggingface.repository import RepositoryManager
from helpers.huggingface.uploader import FileUploader
if TYPE_CHECKING:
from pathlib import Path
class HuggingFaceUploader:
"""Compatibility wrapper for HuggingFace operations.
Maintains the same interface as the old HuggingFaceUploader class
while using the new modular components internally.
"""
@staticmethod
def get_username() -> str:
"""Get authenticated HuggingFace username.
Returns:
HuggingFace username from CLI authentication.
"""
return HuggingFaceClient.get_username()
def upload_readme(self, output_repo: str, readme_path: Path) -> None:
"""Upload or update README file to repository.
Creates repository if needed, handles existing repository updates.
The README is uploaded to the repository root as README.md.
"""
FileUploader.upload_readme(output_repo, readme_path, ensure_repo=True)
def upload_model_file(self, output_repo: str, model_path: Path) -> None:
"""Upload model file to repository.
Uploads GGUF model file to specified repository path. The file
is uploaded with progress tracking suitable for large model files.
"""
FileUploader.upload_model_file(output_repo, model_path)
def _ensure_repo_exists(self, repo_id: str) -> None:
"""Ensure the repository exists, creating it if necessary.
Creates the repository if it doesn't exist and waits briefly
to ensure it's ready for subsequent operations.
"""
RepositoryManager.ensure_repository_exists(repo_id)