File size: 1,879 Bytes
9f72def
 
 
 
 
 
 
 
 
 
 
 
 
eb8ce3a
9f72def
 
 
 
 
 
 
 
94e680d
9f72def
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5de1095
 
9f72def
 
 
 
d34a83d
 
 
 
 
 
9f72def
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
54
55
56
57
58
59
60
61
62
63
64
import os

# One representative (smallest) size per GPU family, covered by the background
# sweep. Any other size can be probed on demand via the API or dashboard.
# Kept to small sizes on purpose: a successful probe holds the reservation
# ~2 s billed at the instance's on-demand rate.
INSTANCE_TYPES = [
    "g4ad.xlarge",
    "g4dn.xlarge",
    "g5.xlarge",
    "g5g.xlarge",
    "g6.xlarge",
    "g6e.xlarge",
    "g7e.2xlarge",
    "gr6.4xlarge",
    "p3.2xlarge",
    "p4d.24xlarge",
    "p4de.24xlarge",
    "p5.48xlarge",
    "p5e.48xlarge",
    "p5en.48xlarge",
    "p6-b200.48xlarge",
    "p6-b300.48xlarge",
]

REGIONS = [
    "us-east-1",
    "us-east-2",
    "us-west-2",
    "eu-west-1",
    "eu-west-2",
    "eu-west-3",
    "eu-north-1",
    "eu-central-1",
]

# Tag put on every probe reservation, used by the startup cleanup sweep.
PROBE_TAG_KEY = "purpose"
PROBE_TAG_VALUE = "capacity-probe"

# Dead-man switch: probe reservations auto-expire even if we crash mid-probe.
PROBE_END_DATE_MINUTES = 30

# Cached probe results older than this are flagged stale in the UI.
STALE_AFTER_SECONDS = int(os.environ.get("STALE_AFTER_SECONDS", "900"))

# Optional background refresh of all types/regions. 0 = disabled (probe on
# demand only). Each full sweep creates+cancels one reservation per offered AZ.
AUTO_REFRESH_MINUTES = int(os.environ.get("AUTO_REFRESH_MINUTES", "0"))

# On the Space this points into the mounted HF bucket (rtrm/gpu-capacity-storage
# on /data) so results survive restarts.
STATE_FILE = os.environ.get(
    "STATE_FILE", os.path.join(os.path.dirname(__file__), "..", "state.json")
)

# Probe history, one JSONL file per day next to the state file.
HISTORY_DIR = os.environ.get(
    "HISTORY_DIR", os.path.join(os.path.dirname(STATE_FILE), "history")
)
HISTORY_LOAD_DAYS = int(os.environ.get("HISTORY_LOAD_DAYS", "90"))

MAX_PROBE_WORKERS = 16