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:
+12
-4
@@ -73,17 +73,25 @@ if ($needInstall) {
|
||||
Get-Date -Format o | Set-Content -LiteralPath $Stamp -Encoding ascii
|
||||
}
|
||||
|
||||
$GpuHome = Join-Path $env:USERPROFILE ".gpu-rent"
|
||||
$EnvFile = Join-Path $GpuHome ".env"
|
||||
$EnvFile = Join-Path $Root ".env"
|
||||
$Example = Join-Path $Root "env.example"
|
||||
if (-not (Test-Path -LiteralPath $EnvFile)) {
|
||||
New-Item -ItemType Directory -Force -Path $GpuHome | Out-Null
|
||||
if (Test-Path -LiteralPath $Example) {
|
||||
Copy-Item -LiteralPath $Example -Destination $EnvFile
|
||||
Write-Host "gpu-rent: created $EnvFile - fill OS_* (docs/setup.md)"
|
||||
Write-Host "gpu-rent: created .env - fill OS_* (docs/setup.md)"
|
||||
}
|
||||
}
|
||||
|
||||
function Copy-IfMissing {
|
||||
param([string]$Src, [string]$Dst, [string]$Label)
|
||||
if ((Test-Path -LiteralPath $Src) -and -not (Test-Path -LiteralPath $Dst)) {
|
||||
Copy-Item -LiteralPath $Src -Destination $Dst
|
||||
Write-Host "gpu-rent: created $Label"
|
||||
}
|
||||
}
|
||||
Copy-IfMissing (Join-Path $Root "models.example.yaml") (Join-Path $Root "models.yaml") "models.yaml"
|
||||
Copy-IfMissing (Join-Path $Root "extensions.example.yaml") (Join-Path $Root "extensions.yaml") "extensions.yaml"
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
& $VenvPy -m gpu_rent @args
|
||||
exit $LASTEXITCODE
|
||||
|
||||
Reference in New Issue
Block a user