110 lines
3.6 KiB
PowerShell
110 lines
3.6 KiB
PowerShell
param(
|
||
[string[]]$Routes = @(),
|
||
[string]$RouteListPath = "",
|
||
[string[]]$SimulationMaps = @("yandex"),
|
||
[string[]]$InterframeMethods = @("optical-flow", "orb", "akaze", "sift", "brisk"),
|
||
[string[]]$LandmarkMethods = @("orb", "akaze", "sift", "brisk"),
|
||
[double[]]$RefMinDistances = @(100),
|
||
[switch]$UseSianSimilarity,
|
||
[switch]$UseGan,
|
||
[switch]$DryRun
|
||
)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||
Set-Location $ProjectRoot
|
||
|
||
function Expand-List {
|
||
param([string[]]$Values)
|
||
|
||
$Expanded = @()
|
||
foreach ($Value in $Values) {
|
||
$Expanded += $Value -split "," | ForEach-Object { $_.Trim() } | Where-Object { $_ }
|
||
}
|
||
return $Expanded
|
||
}
|
||
|
||
$Routes = Expand-List $Routes
|
||
$SimulationMaps = Expand-List $SimulationMaps
|
||
$InterframeMethods = Expand-List $InterframeMethods
|
||
$LandmarkMethods = Expand-List $LandmarkMethods
|
||
|
||
if ($RouteListPath) {
|
||
if (-not (Test-Path $RouteListPath)) {
|
||
throw "Файл со списком маршрутов не найден: $RouteListPath"
|
||
}
|
||
|
||
$RoutesFromFile = Get-Content -Path $RouteListPath |
|
||
ForEach-Object { ($_ -split "#")[0].Trim() } |
|
||
Where-Object { $_ }
|
||
|
||
$Routes += $RoutesFromFile
|
||
$Routes = $Routes | Select-Object -Unique
|
||
}
|
||
|
||
if ($Routes.Count -eq 0) {
|
||
$Routes = Get-ChildItem -Path "trajectories" -Directory |
|
||
Where-Object { Test-Path (Join-Path $_.FullName "positions.pkl") } |
|
||
Sort-Object Name |
|
||
Select-Object -ExpandProperty Name
|
||
}
|
||
|
||
if ($Routes.Count -eq 0) {
|
||
throw "Не найдено маршрутов в trajectories. Сначала выполните build хотя бы для одного маршрута."
|
||
}
|
||
|
||
$Python = Join-Path $ProjectRoot ".venv\Scripts\python.exe"
|
||
if (-not (Test-Path $Python)) {
|
||
$Python = "python"
|
||
}
|
||
|
||
$Total = $Routes.Count * $SimulationMaps.Count * $InterframeMethods.Count * $LandmarkMethods.Count * $RefMinDistances.Count
|
||
$RunIndex = 0
|
||
|
||
Write-Host "Batch run started"
|
||
Write-Host "Routes: $($Routes -join ', ')"
|
||
Write-Host "Total runs: $Total"
|
||
|
||
foreach ($Route in $Routes) {
|
||
foreach ($SimulationMap in $SimulationMaps) {
|
||
foreach ($RefMinDistance in $RefMinDistances) {
|
||
foreach ($InterframeMethod in $InterframeMethods) {
|
||
foreach ($LandmarkMethod in $LandmarkMethods) {
|
||
$RunIndex += 1
|
||
$Args = @(
|
||
"main.py",
|
||
"--mode", "run",
|
||
"--name", $Route,
|
||
"--simulation", $SimulationMap,
|
||
"--ref-min-distance", "$RefMinDistance",
|
||
"--interframe-method", $InterframeMethod,
|
||
"--landmark-method", $LandmarkMethod
|
||
)
|
||
|
||
if ($UseSianSimilarity) {
|
||
$Args += "--use-sian-similarity"
|
||
}
|
||
if ($UseGan) {
|
||
$Args += "--use-gan"
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "[$RunIndex/$Total] route=$Route simulation=$SimulationMap ref=$RefMinDistance interframe=$InterframeMethod landmark=$LandmarkMethod"
|
||
Write-Host "$Python $($Args -join ' ')"
|
||
|
||
if (-not $DryRun) {
|
||
& $Python @Args
|
||
if ($LASTEXITCODE -ne 0) {
|
||
throw "Run failed with exit code $LASTEXITCODE"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Write-Host ""
|
||
Write-Host "Batch run finished. Results are saved by main.py into test_runs."
|