A custom node extension for ComfyUI that provides: - Model version tracking for HuggingFace and CivitAI - Automatic model updates with configurable scheduling - Multi-GPU synchronization with VRAM-based filtering - Metadata management with hash verification Features: - SQLite database for model metadata storage - REST API endpoints for all operations - Web UI panel integrated into ComfyUI menu - Background scheduler for automatic update checks - rsync-based sync to remote machines - VRAM estimation for model filtering Tests: - 17 unit tests covering all library modules - Playwright integration tests for UI verification Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
185 lines
5.4 KiB
Markdown
185 lines
5.4 KiB
Markdown
# ComfyUI-ModelSync
|
|
|
|
**Model Auto-Update & Multi-GPU Sync for ComfyUI**
|
|
|
|
A custom node extension that provides:
|
|
- **Model Version Tracking** - Detect when HuggingFace/CivitAI models have updates
|
|
- **Auto-Update System** - Configurable automatic model downloads
|
|
- **Multi-GPU Sync** - Sync models to secondary machines filtered by VRAM capacity
|
|
- **Metadata Management** - Track installed models with hashes, versions, sources
|
|
|
|
## Features
|
|
|
|
### Model Version Tracking
|
|
- Automatically detect updates for models from HuggingFace and CivitAI
|
|
- Compare local files with remote versions using SHA256 hashes
|
|
- Cache version information to minimize API calls
|
|
|
|
### Auto-Update System
|
|
- Background scheduler for periodic update checks
|
|
- Configurable update intervals
|
|
- Automatic downloads with hash verification
|
|
- Backup old versions before updating
|
|
|
|
### Multi-GPU Sync
|
|
- Sync models to secondary machines using rsync over SSH
|
|
- Filter models by VRAM requirements
|
|
- Generate standalone sync scripts for manual execution
|
|
- Configurable per-target settings
|
|
|
|
### Web UI
|
|
- Integrated panel in ComfyUI interface
|
|
- View all tracked models and their status
|
|
- Configure sync targets and settings
|
|
- Trigger manual updates and syncs
|
|
|
|
## Installation
|
|
|
|
### Using ComfyUI Manager (Recommended)
|
|
|
|
Search for "ModelSync" in ComfyUI Manager and install.
|
|
|
|
### Manual Installation
|
|
|
|
1. Clone this repository into your ComfyUI custom_nodes directory:
|
|
```bash
|
|
cd ComfyUI/custom_nodes
|
|
git clone https://github.com/benfinklea/ComfyUI-ModelSync.git
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
cd ComfyUI-ModelSync
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Restart ComfyUI
|
|
|
|
## Usage
|
|
|
|
### Web Interface
|
|
|
|
1. Click the "Model Sync" button in the ComfyUI menu
|
|
2. **Models Tab**: View and manage tracked models
|
|
- Click "Scan" to discover models in your models directory
|
|
- Click "Check Updates" to query HuggingFace/CivitAI for updates
|
|
- Enable auto-update per model using the checkbox
|
|
- Click "Download" to update individual models
|
|
|
|
3. **Sync Targets Tab**: Configure machines to sync to
|
|
- Add targets with SSH host and models path
|
|
- Set VRAM limits to filter which models sync
|
|
- Click "Sync Now" to sync to a specific target
|
|
|
|
4. **Settings Tab**: Configure global options
|
|
- Enable/disable auto-update
|
|
- Set check interval
|
|
- Toggle download verification and backups
|
|
|
|
### API Endpoints
|
|
|
|
| Endpoint | Method | Description |
|
|
|----------|--------|-------------|
|
|
| `/modelsync/models` | GET | List all tracked models |
|
|
| `/modelsync/models/scan` | POST | Scan filesystem for models |
|
|
| `/modelsync/models/{id}` | GET | Get model details |
|
|
| `/modelsync/models/{id}` | PATCH | Update model settings |
|
|
| `/modelsync/check` | POST | Check models for updates |
|
|
| `/modelsync/download/{id}` | POST | Download model update |
|
|
| `/modelsync/config` | GET/POST | Get/set configuration |
|
|
| `/modelsync/targets` | GET/POST | List/add sync targets |
|
|
| `/modelsync/targets/{id}` | DELETE | Remove sync target |
|
|
| `/modelsync/sync/{id}` | POST | Sync to specific target |
|
|
| `/modelsync/sync` | POST | Sync to all targets |
|
|
| `/modelsync/status` | GET | Get overall status |
|
|
|
|
### Setting Model Sources
|
|
|
|
To enable update checking for a model, set its source URL:
|
|
|
|
```bash
|
|
curl -X PATCH http://localhost:8188/modelsync/models/1 \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"source_url": "https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors"}'
|
|
```
|
|
|
|
Or use the optional workflow node "Set Model Source".
|
|
|
|
### Configuring Sync Targets
|
|
|
|
Add a sync target:
|
|
|
|
```bash
|
|
curl -X POST http://localhost:8188/modelsync/targets \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "secondary-gpu",
|
|
"ssh_host": "user@192.168.1.100",
|
|
"model_path": "/home/user/ComfyUI/models",
|
|
"max_vram_mb": 16000
|
|
}'
|
|
```
|
|
|
|
### VRAM Filtering
|
|
|
|
Models are filtered based on estimated VRAM requirements:
|
|
|
|
| Pattern | Estimated VRAM |
|
|
|---------|----------------|
|
|
| wan, hunyuan, mochi | 48 GB |
|
|
| flux-dev | 24 GB |
|
|
| flux-schnell | 12 GB |
|
|
| sdxl | 12 GB |
|
|
| sd15, sd1.5 | 6 GB |
|
|
| lora | 2 GB |
|
|
|
|
Models larger than the target's `max_vram_mb` will be skipped during sync.
|
|
|
|
## Configuration
|
|
|
|
Default configuration values:
|
|
|
|
| Key | Default | Description |
|
|
|-----|---------|-------------|
|
|
| `auto_update_enabled` | false | Enable automatic updates |
|
|
| `check_interval_hours` | 24 | Hours between update checks |
|
|
| `cache_ttl_hours` | 6 | Hours to cache version info |
|
|
| `verify_downloads` | true | Verify file hash after download |
|
|
| `backup_before_update` | true | Create .bak before replacing |
|
|
| `max_concurrent_downloads` | 2 | Max simultaneous downloads |
|
|
|
|
## Optional Workflow Nodes
|
|
|
|
Three utility nodes are included for workflow integration:
|
|
|
|
- **Model Info (ModelSync)** - Output model metadata (source URL, VRAM, update status)
|
|
- **Check Model Update (ModelSync)** - Check if a specific model has updates
|
|
- **Set Model Source (ModelSync)** - Associate a model with its source URL
|
|
|
|
## Database
|
|
|
|
ModelSync uses SQLite for metadata storage. The database is stored at:
|
|
```
|
|
ComfyUI/custom_nodes/ComfyUI-ModelSync/modelsync.db
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Python 3.10+
|
|
- ComfyUI
|
|
- `huggingface_hub>=0.20.0`
|
|
- `aiohttp>=3.9.0`
|
|
- SSH and rsync (for multi-GPU sync)
|
|
|
|
## License
|
|
|
|
MIT License - see LICENSE file for details.
|
|
|
|
## Contributing
|
|
|
|
Contributions are welcome! Please open an issue or pull request on GitHub.
|
|
|
|
## Support
|
|
|
|
For issues and feature requests, please use the [GitHub issue tracker](https://github.com/benfinklea/ComfyUI-ModelSync/issues).
|