param([Parameter(Mandatory=$true)][string]$Release,[switch]$Apply) $ErrorActionPreference='Stop' $root='D:\NDC_MISSIONCORE\datasets\urban-learning' $runtime='D:\NDC_MISSIONCORE\runtime\simulation' $python="$runtime\isaac-sim-6.1.0\kit\python\python.exe" $manifest=Get-Content "$Release\release.json" -Raw | ConvertFrom-Json foreach($f in $manifest.files.psobject.Properties){ $path=Join-Path $Release $f.Name if((Get-FileHash $path -Algorithm SHA256).Hash.ToLower() -ne $f.Value){throw "Release identity mismatch: $($f.Name)"} } if(-not (Test-Path $python)){throw 'Worker Python unavailable'} $image=& docker image inspect $manifest.image --format '{{.Id}}' if($LASTEXITCODE -ne 0 -or $image -ne $manifest.image){throw 'Pinned renderer unavailable'} $arguments="-B -u `"$Release\worker.py`" --root `"$root`" --state `"$runtime\state`" --token-file `"$runtime\private\worker.token`"" if(-not $Apply){Write-Output $arguments;exit} New-Item -ItemType Directory -Force -Path $root | Out-Null $old=Get-ScheduledTask -TaskName 'ndc-semantic-learning-worker' -ErrorAction SilentlyContinue if($old){ if($old.State -eq 'Running'){throw 'Stop the owned learning worker only after checking its active job'} Export-ScheduledTask -TaskName 'ndc-semantic-learning-worker' | Set-Content "$root\previous-task.xml" } $action=New-ScheduledTaskAction -Execute $python -Argument $arguments -WorkingDirectory $Release $principal=New-ScheduledTaskPrincipal -UserId ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name) -LogonType Interactive -RunLevel Limited $trigger=New-ScheduledTaskTrigger -AtLogOn -User $principal.UserId $settings=New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -ExecutionTimeLimit ([TimeSpan]::Zero) -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries Register-ScheduledTask -TaskName 'ndc-semantic-learning-worker' -Action $action -Principal $principal -Trigger $trigger -Settings $settings -Force | Out-Null Start-ScheduledTask -TaskName 'ndc-semantic-learning-worker' Write-Output 'Installed ndc-semantic-learning-worker; data root is separate from runtime and release'