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
+11 -5
View File
@@ -52,11 +52,17 @@ if [[ ! -f "$STAMP" || "$ROOT/pyproject.toml" -nt "$STAMP" ]]; then
date -u +"%Y-%m-%dT%H:%M:%SZ" >"$STAMP"
fi
GPU_HOME="${HOME}/.gpu-rent"
if [[ ! -f "$GPU_HOME/.env" && -f "$ROOT/env.example" ]]; then
mkdir -p "$GPU_HOME"
cp "$ROOT/env.example" "$GPU_HOME/.env"
echo "gpu-rent: created $GPU_HOME/.env - fill OS_* (see docs/setup.md)"
if [[ ! -f "$ROOT/.env" && -f "$ROOT/env.example" ]]; then
cp "$ROOT/env.example" "$ROOT/.env"
echo "gpu-rent: created .env - fill OS_* (see docs/setup.md)"
fi
if [[ ! -f "$ROOT/models.yaml" && -f "$ROOT/models.example.yaml" ]]; then
cp "$ROOT/models.example.yaml" "$ROOT/models.yaml"
echo "gpu-rent: created models.yaml"
fi
if [[ ! -f "$ROOT/extensions.yaml" && -f "$ROOT/extensions.example.yaml" ]]; then
cp "$ROOT/extensions.example.yaml" "$ROOT/extensions.yaml"
echo "gpu-rent: created extensions.yaml"
fi
exec "$VENV_PY" -m gpu_rent "$@"