魔乐 (Modelers) / 魔塔 (ModelScope) / GitCode 模型自动同步器
A background service that automatically syncs AI model weights across three Chinese model hosting platforms — Modelers (魔乐社区), ModelScope (魔搭), and GitCode.
- Bidirectional model-level sync — detects models that exist on one platform but not another, and mirrors them automatically
- File-level delta sync — for models present on both platforms, compares individual files by SHA256 and only uploads what changed
- GitCode mirror creation — automatically creates GitCode repos by importing from ModelScope
- Daemon mode — runs continuously as a background service with a work queue, refreshing periodically
- Resume support — parallel SHA256 comparison and selective re-download for broken/partial syncs
- README/license handling — strips YAML front matter from READMEs, auto-adds license information on Modelers
Modelers (魔乐) <── bidirectional model sync ──> ModelScope (魔搭)
│
│ (model discovery only)
▼
GitCode
- Model-level sync is bidirectional between Modelers and ModelScope
- File-level sync is one-way: ModelScope → Modelers
- GitCode repos are created via ModelScope
.gitimport URLs, with a prompt to enable pull mirror mode
The daemon maintains an in-memory work queue (deque) refreshed every 12 hours:
| Work Item Type | Format | Description |
|---|---|---|
| Model sync | [model_name, target_platform] |
Sync entire model to target platform |
| File update | [model_name, platform, file_name, "update"] |
Upload changed file |
| File delete | [model_name, platform, file_name, "delete"] |
Remove stale file from Modelers |
- Python 3.8+
- Linux server with sufficient disk space for model weights (typically hundreds of GB)
- API tokens for ModelScope, Modelers (openMind), and GitCode
# Clone the repository
git clone <repo-url>
cd Eco-Tech-Sync
# Install dependencies
pip install modelscope openmind_hub pyyaml python-dotenv env_yaml apscheduler tqdmWEIGHTS_PATH="your_weight_work_path"
MODELERS_TOKEN="your_modelers_token"
MODELERS_REPO_NAME="YourOrgName"
SCOPE_TOKEN="your_modelscope_token"
SCOPE_REPO_NAME="YourOrgName"
GITCODE_TOKEN="your_gitcode_token"
GITCODE_REPO_NAME="YourOrgName"The config uses ${ENV_VAR} placeholders resolved from .env. Key sections:
| Section | Description |
|---|---|
global |
Local weights storage path, logger name |
modelscope_cfg |
ModelScope API credentials and supported licenses |
modelers_cfg |
Modelers API credentials and supported licenses |
gitcode_cfg |
GitCode API credentials and ModelScope base URL for imports |
Default: daily rotating logs in log/ with 90-day retention.
bash run.shThis launches server-work.py as a background process with nohup. The daemon:
- Generates a work queue by comparing all three platforms
- Processes sync tasks one at a time (60s pause between tasks)
- Refreshes the work queue every 12 hours
- Sleeps 30 minutes when queue is empty before checking again
python static_work.pyComputes the full work queue once, processes all items, then reports success/failure.
bash run-single.shSyncs a single specified model. Edit single_sync.py to change the target model name.
bash run-resume.shCompares local SHA256 hashes with remote, downloads only changed .safetensors files. Uses parallel processing (64 workers) for fast comparison.
model_syn/
├── server-work.py # Main daemon (continuous background sync)
├── static_work.py # One-shot batch sync
├── single_sync.py # Single model sync
├── resume_sync.py # Resume/repair broken downloads
├── park_sync.py # Sync from Modelers_Park namespace
│
├── utils/ # Core library
│ ├── model_tools.py # Work queue generation, file diff, README/license utils
│ ├── model_updown.py # All download/upload/sync operations
│ └── gitcode_conn.py # GitCode API client
│
├── config.yaml # Main configuration
├── logging_config.yaml # Logging configuration
├── .env # Secrets & environment variables (gitignored)
│
├── run.sh # Launch daemon
├── run-single.sh # Launch single sync
├── run-resume.sh # Launch resume sync
│
└── log/ # Logs (gitignored)
├── info.log # Application log (daily rotation)
└── server-std.log # Daemon stdout
- Only models containing
.safetensorsweight files are synced; non-weight repos are skipped - Default LICENSE files automatically generated by ModelScope are detected and filtered out during comparison
- The
.envfile containing tokens is excluded from git via.gitignore - Logs and test scripts are excluded from version control
- All shell scripts set
HUB_WHITE_LIST_PATHSand cache directories for Modelers SDK compatibility