Add support for gpu-rent.vars and enhance git update functionality

- Updated .gitignore to include gpu-rent.vars.
- Modified env.example to introduce the UPDATE_GIT variable for controlling git updates during execution.
- Implemented Import-GpuRentVars function in gpu-rent.ps1 to load environment variables from gpu-rent.vars.
- Enhanced gpu-rent.sh to support loading variables from gpu-rent.vars and added logic for handling default and extra arguments.
- Updated CLI documentation to reflect the new gpu-rent.vars file and its usage in configuration.
- Improved bootstrap and provisioning logic to conditionally perform git updates based on the new configuration.
This commit is contained in:
Leonid Pershin
2026-08-21 05:01:53 +03:00
parent ec42830579
commit a9cf2e0f90
23 changed files with 515 additions and 39 deletions
+39 -1
View File
@@ -12,6 +12,33 @@ try {
} catch {
}
function Import-GpuRentVars {
param([Parameter(Mandatory = $true)][string]$Path)
if (-not (Test-Path -LiteralPath $Path)) { return }
Get-Content -LiteralPath $Path -Encoding UTF8 | ForEach-Object {
$line = $_.Trim()
if (-not $line -or $line.StartsWith("#")) { return }
if ($line -match '^(?i)export\s+') {
$line = $line.Substring($Matches[0].Length).Trim()
}
$eq = $line.IndexOf("=")
if ($eq -lt 1) { return }
$key = $line.Substring(0, $eq).Trim()
$val = $line.Substring($eq + 1).Trim()
if ($val.Length -ge 2) {
$q = $val[0]
if (($q -eq '"' -or $q -eq "'") -and $val[-1] -eq $q) {
$val = $val.Substring(1, $val.Length - 2)
}
}
if (-not $key) { return }
$existing = [Environment]::GetEnvironmentVariable($key, "Process")
if ([string]::IsNullOrEmpty($existing)) {
Set-Item -Path "Env:$key" -Value $val
}
}
}
function Test-Python311 {
param(
[Parameter(Mandatory = $true)][string]$Exe,
@@ -91,7 +118,18 @@ function Copy-IfMissing {
}
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"
Copy-IfMissing (Join-Path $Root "gpu-rent.vars.example") (Join-Path $Root "gpu-rent.vars") "gpu-rent.vars"
Import-GpuRentVars (Join-Path $Root "gpu-rent.vars")
$InvokeArgs = @($args)
if ($InvokeArgs.Count -eq 0 -and $env:GPU_RENT_DEFAULT_ARGS) {
$InvokeArgs = @($env:GPU_RENT_DEFAULT_ARGS -split '\s+' | Where-Object { $_ })
}
if ($env:GPU_RENT_EXTRA_ARGS) {
$InvokeArgs += @($env:GPU_RENT_EXTRA_ARGS -split '\s+' | Where-Object { $_ })
}
$ErrorActionPreference = "Continue"
& $VenvPy -m gpu_rent @args
& $VenvPy -m gpu_rent @InvokeArgs
exit $LASTEXITCODE