forked from gittensor-ai-lab/sparkinfer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh_box.py
More file actions
53 lines (41 loc) · 1.53 KB
/
Copy pathssh_box.py
File metadata and controls
53 lines (41 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Eval box transport — vast.ai (default) or a fixed SSH box.
Set EVAL_TRANSPORT=ssh to use a pinned bare-metal GPU (EVAL_SSH_HOST / EVAL_SSH_PORT).
Leave unset or EVAL_TRANSPORT=vast to reuse a pinned vast.ai instance (no auto-rent/stop).
Legacy alias: EVAL_USE_VAST=0 also selects the SSH box (requires EVAL_SSH_HOST).
"""
import os
_TRANSPORT = os.environ.get("EVAL_TRANSPORT", "").strip().lower()
def vast_enabled():
"""True when vast.ai provisioning should run (the default)."""
if _TRANSPORT == "ssh":
return False
if _TRANSPORT == "vast":
return True
use_vast = os.environ.get("EVAL_USE_VAST", "").strip().lower()
if use_vast in ("0", "false", "no"):
return False
return True
def ssh_box_endpoint():
"""Return (host, port) for the fixed SSH eval box, or None if not configured."""
direct = os.environ.get("EVAL_SSH", "").strip()
if direct:
host, sep, port = direct.partition(":")
if not host:
return None
return host.strip(), int(port or "22")
host = os.environ.get("EVAL_SSH_HOST", "").strip()
if not host:
return None
return host, int(os.environ.get("EVAL_SSH_PORT", "22"))
def ssh_box_arg():
"""host:port string for vast_eval.py --ssh, or empty."""
ep = ssh_box_endpoint()
if not ep:
return ""
host, port = ep
return f"{host}:{port}"
def ssh_box_enabled():
"""Use the fixed SSH box instead of vast.ai."""
if vast_enabled():
return False
return ssh_box_endpoint() is not None