param( [switch]$DryRun, [int]$Epochs = 20, [int]$BatchSizePerGpu = 600, [string]$HfCacheMode = "auto", [string]$HfCacheDir = ".hf_cache", [string]$MachineTag = "win" ) $ErrorActionPreference = "Stop" $repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..") Set-Location $repoRoot git pull --ff-only origin main $prepared = Get-ChildItem -Path "data" -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^sinhala_tts_batch(\d+)_custom$' } | Where-Object { Test-Path (Join-Path $_.FullName "raw.arrow") } | ForEach-Object { [PSCustomObject]@{ Number = [int]([regex]::Match($_.Name, '^sinhala_tts_batch(\d+)_custom$').Groups[1].Value) DatasetName = "sinhala_tts_batch$([regex]::Match($_.Name, '^sinhala_tts_batch(\d+)_custom$').Groups[1].Value)" } } | Sort-Object Number if (-not $prepared) { throw "No prepared batches found under data\\sinhala_tts_batch*_custom" } $lockFile = Join-Path $repoRoot "ACTIVE_RUNS.md" $lockContent = if (Test-Path $lockFile) { Get-Content $lockFile -Raw } else { "" } $selected = $null foreach ($p in $prepared) { if ($lockContent -match [regex]::Escape($p.DatasetName)) { continue } $selected = $p break } if (-not $selected) { throw "All available prepared batches appear claimed in ACTIVE_RUNS.md" } $datasetName = $selected.DatasetName $expName = "F5TTS_v1_Base_${MachineTag}_batch$($selected.Number)" $startedUtc = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ") if (-not (Test-Path $lockFile)) { @( "# ACTIVE RUNS", "# machine | dataset_name | exp_name | started_utc" ) | Set-Content -LiteralPath $lockFile -Encoding UTF8 } Add-Content -LiteralPath $lockFile -Value ("| {0} | {1} | {2} | {3} |" -f $MachineTag, $datasetName, $expName, $startedUtc) $cmd = @( ".\scripts\run_finetune_safe.ps1", "-DatasetName", $datasetName, "-ExpName", $expName, "-Epochs", "$Epochs", "-BatchSizePerGpu", "$BatchSizePerGpu", "-HfCacheMode", $HfCacheMode, "-HfCacheDir", $HfCacheDir ) Write-Output ("Selected batch: {0}" -f $datasetName) Write-Output ("Command: {0}" -f ($cmd -join " ")) if ($DryRun) { Write-Output "Dry run only; not launching." exit 0 } & .\scripts\run_finetune_safe.ps1 ` -DatasetName $datasetName ` -ExpName $expName ` -Epochs $Epochs ` -BatchSizePerGpu $BatchSizePerGpu ` -HfCacheMode $HfCacheMode ` -HfCacheDir $HfCacheDir