Refactor environment and configuration management

- Updated the project structure to store configuration files (.env, models.yaml, extensions.yaml) in the project root instead of the user's home directory.
- Enhanced the setup process to automatically copy example files to the project root on first run.
- Implemented a migration function to transfer legacy configuration files from the user's home directory to the new project structure.
- Revised documentation to reflect changes in file locations and setup instructions.
- Improved code readability and maintainability by refactoring path management functions.
This commit is contained in:
Leonid Pershin
2026-08-21 03:20:18 +03:00
parent c2ca39a4a7
commit 343f741baa
22 changed files with 202 additions and 90 deletions
+9 -15
View File
@@ -67,27 +67,21 @@ ComfyUI в `dlbackend` качается всегда. Речь только о *
## Манифест
Пример в репозитории: [`models.example.yaml`](../models.example.yaml). Рабочая копия: `~/.gpu-rent/models.yaml` (или путь `MODELS_MANIFEST`).
Пример в репозитории: [`models.example.yaml`](../models.example.yaml). Рабочая копия: `models.yaml` в корне репо (или путь `MODELS_MANIFEST`).
Идентификатор — **Civitai model version id**, не имя файла и не «последняя версия модели» (она плывёт).
```yaml
# ~/.gpu-rent/models.yaml
# models.yaml — пример: Krea 2 + LoRA (см. models.example.yaml)
checkpoint:
- version_id: 2514310
- url: https://civitai.red/models/2786499/realism-by-stable-yogi-krea2?modelVersionId=3231611
lora:
- version_id: 123456
vae:
- version_id: 789012
embedding:
- version_id: 111
controlnet:
- version_id: 222
upscaler:
- version_id: 333
- url: https://civitai.red/models/2268008/realistic-snapshot-z-image-turbo-krea-2?modelVersionId=3084537
- url: https://civitai.red/models/2187487/cutifyier?modelVersionId=3107521
- url: https://civitai.red/models/1134895/2000s-analog-core?modelVersionId=3103914
```
Допустимо вместо `version_id` поле `url` страницы модели/версии — CLI вынимает id. Хосты `civitai.com`, `civitai.red`, `civitai.green` равнозначны (зелёный редиректит на `.com`). Несколько файлов у версии: берём `files[]` с `"primary": true`, иначе SafeTensor / fp16.
Допустимо вместо `url` поле `version_id` (число из `modelVersionId=`). Хосты `civitai.com`, `civitai.red`, `civitai.green` равнозначны (зелёный редиректит на `.com`). Несколько файлов у версии: берём `files[]` с `"primary": true`, иначе SafeTensor / fp16.
Типы манифеста → каталоги SwarmUI (`ModelRoot` = `Models`):
@@ -103,7 +97,7 @@ upscaler:
Тип в yaml задаёт **куда класть**, даже если Civitai назвал иначе. Если API-тип совсем другой — предупреждение, кладём по yaml.
В git не коммитить рабочий манифест с личными чекпоинтами. В примере — вымышленные id.
В git не коммитить рабочий манифест с личными чекпоинтами. В `models.example.yaml` — стартовый набор Krea 2 (чекпоинт + три LoRA); скопируй и дополни под себя.
## Civitai API (.com / .red)
@@ -169,6 +163,6 @@ REST не раздвоился: те же `/api/v1/...` на обоих хост
```env
CIVITAI_API_TOKEN=
CIVITAI_API_HOST=civitai.red # полный каталог; civitai.com = только SFW
MODELS_MANIFEST= # пусто = ~/.gpu-rent/models.yaml
MODELS_MANIFEST= # пусто = <repo>/models.yaml
LOCAL_MODELS_DIR= # пусто = <корень приложения>/Models
```