PhotonTTS / code /tools /remote_sh.py
hello-test1's picture
sync code
7e2301f verified
Raw History Blame Contribute Delete
908 Bytes
"""Run a shell command on the remote GPU box and print its output.
MARIMO_URL=... MARIMO_TOKEN=... python tools/remote_sh.py "cd /root/PhotonTTS && pytest -q"
"""
from __future__ import annotations
import os
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from push_remote import DEFAULT_EXEC, run_remote # noqa: E402
def main():
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
cmd = " ".join(sys.argv[1:])
timeout = int(os.environ.get("REMOTE_TIMEOUT", 3600))
code = (
"import subprocess\n"
f"r = subprocess.run({cmd!r}, shell=True, capture_output=True, text=True, timeout={timeout})\n"
"print(r.stdout[-20000:], r.stderr[-5000:], f'[exit {r.returncode}]')\n"
)
print(run_remote(code, os.environ["MARIMO_URL"], os.environ["MARIMO_TOKEN"], DEFAULT_EXEC))
if __name__ == "__main__":
main()