Compare commits

...
Author SHA1 Message Date
minh hoangandGitHub 4f5d943a15 fix(monitors): allow overriding the platform base URL via $PRIME_API_BASE (#3287)
The prime monitor's TrainRun hardcodes the production public API
(https://api.primeintellect.ai/api/v1/rft). Managed launches need to point
it at the platform's internal ingestion path instead, and non-prod
environments currently post metrics to prod (where their per-run tokens
401) — silently, since uploads are fire-and-forget.

$PRIME_API_BASE is taken verbatim when set (the platform already injects
it on managed orchestrator pods as {SERVICE_URL}/api/internal/rft);
otherwise the default is unchanged. Resolved once in __init__ and stored,
since the atexit _mark_failed hook must agree with the client.
2026-08-17 15:51:35 -07:00
+4 -2
View File
@@ -22,6 +22,7 @@ from prime_rl.utils.logger import get_logger
from prime_rl.utils.utils import sanitize
BASE_URL = "https://api.primeintellect.ai/api/v1/rft"
BASE_URL_VAR = "PRIME_API_BASE"
API_KEY_VAR = "PRIME_API_KEY"
SAMPLE_SCHEMA = pa.schema(
@@ -129,13 +130,14 @@ class TrainRun:
self.id: str | None = None
self.logger = get_logger()
self._tasks: set[asyncio.Task] = set()
self.base_url = (os.getenv(BASE_URL_VAR) or BASE_URL).rstrip("/")
self.headers = {
"Authorization": f"Bearer {api_key}",
"x-api-key": api_key,
"Content-Type": "application/json",
}
self.client = httpx.AsyncClient(
base_url=BASE_URL,
base_url=self.base_url,
headers=self.headers,
timeout=30,
transport=httpx.AsyncHTTPTransport(retries=3),
@@ -246,7 +248,7 @@ class TrainRun:
self.logger.info(f"Marking platform run {self.id} as failed")
try:
httpx.put(
f"{BASE_URL}/external-runs/{self.id}/status",
f"{self.base_url}/external-runs/{self.id}/status",
headers=self.headers,
json={"status": "failed"},
timeout=30,