Files
gpu-rent/tmp_build_ext.py

33 lines
1.2 KiB
Python

"""Upload local swarm-assistent sources to the VM and build them there."""
import sys
from pathlib import Path
from gpu_rent.config import load_config
from gpu_rent.state import load_state
from gpu_rent.ssh_ops import _connect, put_file_on, run_ssh_on
LOCAL = Path(r"D:\Github\swarm-assistent")
REMOTE = "/opt/swarmui/src/Extensions/swarm-assistent"
cfg = load_config(require_auth=True)
state = load_state()
client = _connect(cfg, state.floating_ip)
try:
names = sorted(p.name for p in LOCAL.glob("*.cs"))
print(f"upload {len(names)} .cs files")
run_ssh_on(client, f"sudo -n chown -R $USER {REMOTE}", check=False)
for name in names:
put_file_on(client, LOCAL / name, f"{REMOTE}/{name}")
put_file_on(client, LOCAL / "SwarmAssistentExtension.csproj", f"{REMOTE}/SwarmAssistentExtension.csproj")
out = run_ssh_on(
client,
"export PATH=$HOME/.dotnet:$PATH DOTNET_CLI_TELEMETRY_OPTOUT=1; "
f"cd /opt/swarmui && dotnet build {REMOTE}/SwarmAssistentExtension.csproj -v m 2>&1 | tail -n 40",
check=False,
timeout=600,
)
sys.stdout.write(out)
finally:
client.close()