Pulp Hugging Face Plugin - A Pulp plugin for managing Hugging Face Hub content with pull-through caching support.
- Pull-through caching for Hugging Face content (models, datasets, spaces)
- Authentication support via HF tokens for private repositories
- API proxying to forward requests to Hugging Face Hub
- File download caching and serving
- Framework: Django-based Pulp plugin
- Python: 3.9-3.12
- Core Dependencies: pulpcore (3.105.0-3.140), httpx
- Version: 0.4.0.dev
pulp_hugging_face/
├── app/
│ ├── models.py - Core models (Content, Remote, Repository, Distribution)
│ ├── viewsets.py - REST API viewsets
│ ├── serializers.py - API serializers
│ ├── handler.py - Custom content handler
│ ├── tasks/ - Async tasks (sync, publish)
│ └── migrations/ - Database migrations
└── tests/ - Test suite structure (functional, unit, performance)
- HuggingFaceContent - Represents cached files from HF Hub
- HuggingFaceRemote - Configuration for fetching from HF Hub
- HuggingFaceDistribution - Serves content with pull-through caching
- HuggingFaceRepository - Groups cached content
- REST API fully functional
- Pull-through caching implemented
- CLI support planned but not yet implemented
- Active development (version 0.4.0.dev)
- Create a remote pointing to huggingface.co
- Create a distribution with the remote for pull-through caching
- Access HF content through Pulp (automatically cached on first request)
- Subsequent requests served from cache
The plugin uses custom handlers to inject HF-compatible headers and manage the caching lifecycle. The HuggingFaceDistribution model includes a custom content_headers_for() method that adds Hugging Face Hub compatible headers like X-Repo-Commit, X-Linked-ETag, and proper Content-Disposition headers to ensure compatibility with HF CLI tools.