nemo_gym.h2_ping_sidecar.launcher
nemo_gym.h2_ping_sidecar.launcher
Start, supervise and stop the h2-ping-sidecar for gym env start, and point model URLs at it.
H2PingSidecarManager is the entry point. It runs the proxy as an ordinary child process of
the process that starts the Gym servers (RunHelper), so the proxy is always on the same node
as the model servers that call it, including when RunHelper itself runs inside a Ray actor.
Module Contents
Classes
Functions
Data
API
Owns the sidecar processes a run started.
Raise if any sidecar has stopped. Called from Gym’s poll loop.
The sidecar processes this run owns: one child process per instance.
One message per sidecar that is no longer running.
Launch every instance and wait until each has bound its port; returns one summary line each.
SIGTERM every sidecar (it drains in-flight requests), then SIGKILL stragglers.
Bases: RuntimeError
The sidecar could not be configured, started or kept running.
go env GOVERSION of the Go on PATH, or an empty string when there is none.
Short hash of the Go sources the binary is built from.
A binary built from older sources must never be reused, so the hash is part of the cache path.
Compile the bundled Go source into output_path.
The compiler writes to a private temporary file that is moved into place afterwards, so a concurrent run sharing the cache never executes a half-written binary.
Where the sidecar built from the current sources lives: <cache>/<sources hash>/<go version>/.
The proxy is mostly Go’s own net/http and crypto/tls, whose fixes ship as Go releases, so
a binary built by a Go that has since been replaced is not reused: with Go on PATH the exact
version is part of the path. Without Go nothing can be built, so any binary already built from
these sources is used (the newest one), which lets a node without Go run a prebuilt cache.
Build the config from the optional top-level sidecar: block; absent means disabled.
The sidecar executable, building it first when allowed and missing.
Point every model URL aimed at an instance’s upstream at that instance’s local address, in place.
Covers any *base_url key (a string or a list of strings) of a model server under
responses_api_models; top-level keys such as policy_base_url are left as they are. The
resolved value is what gets matched, so a URL that comes from a resolver such as
${oc.env:JUDGE_URL} or from an alias such as ${policy_base_url} is routed through the
sidecar too, and is materialized as a literal in memory for that field only. A field that aliases
a whole list is rewritten as a resolved copy, so the list it points at is never changed.
Raises SidecarError for a value that is not a parseable URL.
Environment for the child: ours, plus the Go runtime limits from the config.
Start the sidecar when sidecar.enabled and point model URLs at it.
Returns the manager to poll and stop later, or None when the feature is off. Raises
SidecarError (after stopping anything it started) when it cannot be brought up. Call it after
initialize_ray() and before the config is serialized for the servers.
Everything that can be checked without side effects is checked first, so a bad config fails with no process started and the live config untouched. Once the proxy is running, any later failure or interrupt stops it before the error propagates, because nothing else owns it yet.