nemo_gym.base_environment_server
nemo_gym.base_environment_server
Shared lifecycle for environment servers.
Module Contents
Classes
Data
API
Bases: SimpleServer, Generic[EpisodeRequestT, EpisodeResponseT]
Expose a typed episode protocol with shared limits and cleanup.
Aggregate per-rollout scores into task-level metrics.
Record that a protocol step completed; state names the next step and what it needs.
While a checkpoint is open the episode parks here until resume.
A replacement attempt
that continues a checkpoint receives the latest recorded state from checkpoint_continuation.
Pass a function when building state costs something: it is called only with checkpointing on.
Return the protocol state this attempt continues from a checkpoint, once, or None.
Mark this episode as a restart: a server it uses cannot capture its part, such as a restart-only agent.
Call it when a seed reply says so (nemo_gym._checkpoint.steps.seed_restarts).
The episode then never holds up a checkpoint and is never exported; after a crash,
the controller starts it over from its input.
Run one protocol step in wait or replay mode (see nemo_gym._checkpoint.steps).
Use replay only for a step that is safe to run again after a crash
and does not change checkpointed state; everything else waits.
Run one concrete environment protocol.
Take part in partial-rollout checkpoints when they are enabled.
Every episode is tracked.
A protocol that records boundaries (checkpoint_boundaries) continues after a restore;
the episodes of a protocol that records none are restarts,
which never hold up a checkpoint and start over from their input after a crash.
Call this from any setup_webserver that builds its own app.
Bases: BaseRunServerInstanceConfig
Configure protocol-neutral episode limits.
Hold bounded process-local cleanup callbacks for one episode.
Callbacks:
- are process-local Python objects, although they may issue remote close requests;
- run sequentially in LIFO order, each with its own cleanup timeout;
- must be idempotent because a timed-out remote request may have succeeded;
- are lost on process or host failure, so remote owners need expiry or reaping.
Callback failures or timeouts do not prevent later owners from tearing down their resources. Total cleanup is bounded by the number of registered callbacks times the per-callback timeout. Cleanup has no durable retry after this context is discarded.
Close one registered participant at a protocol boundary.
Run this idempotent callback once.
The episode timeout bounds calls made during the protocol. The context’s cleanup timeout bounds callbacks left for final unwinding.
Bases: Exception
Carry a failure that belongs in the episode response.