Files
NODEDC_MISSION_CORE/simulation/ai-polygon/start_worker.py
T

45 lines
1.5 KiB
Python

"""Start the prepared Worker and its private tunnel in one foreground SSH session."""
import argparse
import base64
import os
import re
parser = argparse.ArgumentParser()
parser.add_argument("--release", required=True, help="16-character build_bundle identity prefix")
parser.add_argument("--once", action="store_true", help="Exit after one episode")
args = parser.parse_args()
if not re.fullmatch(r"[a-f0-9]{16}", args.release):
parser.error("release must be a 16-character lowercase hexadecimal bundle identity")
script = r"""
$ErrorActionPreference='Stop'
$ProgressPreference='SilentlyContinue'
[Console]::OutputEncoding=[System.Text.Encoding]::UTF8
$b='D:\NDC_MISSIONCORE\runtime\simulation'
$worker="$b\releases\ai-polygon-RELEASE\simulation\ai-polygon\worker.py"
& "$b\isaac-sim-6.1.0\kit\python\python.exe" -u $worker `
--token-file "$b\private\worker.token" --state "$b\state" `
--isaac "$b\isaac-sim-6.1.0" ONCE
exit $LASTEXITCODE
""".replace("RELEASE", args.release).replace("ONCE", "--once" if args.once else "")
encoded = base64.b64encode(script.encode("utf-16-le")).decode()
os.execvp(
"ssh",
[
"ssh",
"-T",
"-o",
"BatchMode=yes",
"-o",
"ExitOnForwardFailure=yes",
"-o",
"ServerAliveInterval=5",
"-o",
"ServerAliveCountMax=3",
"-R",
"127.0.0.1:18081:127.0.0.1:8000",
"mission-gpu",
"powershell.exe -NoProfile -NonInteractive -EncodedCommand " + encoded,
],
)