nemo_gym.global_config
nemo_gym.global_config
Module Contents
Classes
Functions
Data
ALLOW_OPENAI_VERSION_SKEW_KEY_NAME
ALLOW_UNSUPPORTED_PAIRING_ENV_VAR_NAME
ALLOW_UNSUPPORTED_PAIRING_KEY_NAME
MODEL_CALL_CAPTURE_DIR_KEY_NAME
MODEL_ENDPOINT_READINESS_TIMEOUT_KEY_NAME
NEMO_GYM_CONFIG_DICT_ENV_VAR_NAME
NEMO_GYM_CONFIG_PATH_ENV_VAR_NAME
NEMO_GYM_RESERVED_TOP_LEVEL_KEYS
OBSERVABILITY_ENABLED_KEY_NAME
RAY_HEAD_NODE_ADDRESS_KEY_NAME
RESOURCES_SERVER_TYPE_KEY_NAME
RESPONSES_CREATE_PARAMS_KEY_NAME
SKIP_VERIFICATION_REWARD_KEY_NAME
UVICORN_TIMEOUT_WORKER_HEALTHCHECK
_COMPOSED_AGENT_CARRY_OVER_KEYS
API
Bases: BaseModel
Return every top-level agent instance in the config.
Merge the override held for name onto the composed agent, in place, after the bindings.
Move the environment’s bindings onto the composed agent config, in place.
A binding left explicitly unset is carried over still unset, so it is reported rather than silently resolving to whatever the incoming agent happens to declare. It needs its own branch because OmegaConf reports a ’???’ value as absent.
Rename the instance after swapping the agent.
Substituting the trailing agent type keeps the environment prefix that makes the name readable
(gpqa_mcqa_simple_agent -> gpqa_mcqa_hermes_agent); names not ending in their agent type just
gain the suffix. Safe because routing resolves task_source through the resources server edge,
not through this name.
The instance names composition will produce, worked out before it runs.
Take command line overrides naming an instance composition is about to create out of the dict.
That instance does not exist yet, so merging them now would build a partial server beside it. Returned to be applied to the composed agent instead.
True when the agent declares a resources_server but leaves its name unset, marking it a swap source.
Reject routing that sends rows to an instance the swap renamed away.
Destinations name a server that has to exist: agent_name, agent_map values and fan_out
entries. Their keys are matching bases read off the data, so those may name the old instance.
Report held overrides that named an instance composition did not produce.
Reject swapping source onto any target whose resources server does not declare support for it.
Compatibility is declared verifier-side because that is where it is known: an environment’s author knows which harnesses score their task correctly, while a generic harness cannot know that for every environment. A server that declares nothing accepts any harness.
The agent’s resources_server block, or None when it declares none.
Selected rather than indexed because a self-contained agent omits the key, which a struct-mode config rejects outright.
Map the pre-swap instance name onto the composed one, for rows stamped before it happened.
Only a matching base is added, so a route the user declared still wins.
True when the agent has a task to hand over, so another agent can take its place.
Self-contained agents own their environment and declare no resources_server; swapping one out
would leave the incoming agent with nothing to bind to.
Return the dotted paths of every unset (OmegaConf ’???’) leaf, without raising.
We convert to a plain container with resolve=False, throw_on_missing=False so that
neither MISSING values nor unresolved interpolations (${...}) cause an exception — then
walk the plain structure. Iterating or indexing the live DictConfig would raise.
Rehost every other agent instance on the config’s unbound agent, then drop that agent.
held_agent_overrides are command line overrides keyed by the name each instance is renamed to.
Returns the new total config_paths and the extra configs, ordered for merging.
Two rules decide precedence:
- A config named in another config’s
config_pathsis inner. The config that pulled it in overrides it, however deep the nesting goes. - Configs listed together are siblings, in the order they were listed. A later sibling overrides an earlier one, and so does everything it pulled in.
The returned configs are ordered so that a left-to-right OmegaConf.merge
produces both rules: the include tree flattened so that a config follows
everything it pulled in, with each subtree kept contiguous.
Fail fast with one actionable error listing every unset ’???’ value.
Without this, the first unset value surfaces deep in the run pipeline as an opaque omegaconf MissingMandatoryValue, one field at a time and with no override guidance.
Fail fast if a run has no server instances to start.
Without this, gym env start with an empty/omitted config_paths starts the head server and Ray
and then hangs with nothing to run. We catch it before Ray initialises with an actionable
message instead.
Bases: BaseModel
A top-level agent instance, with its single agent type already unwrapped.
Set logging to DEBUG when verbose is in the config. Runs in the CLI process and, because the
config dict is forwarded to every spun-up server, in each server process too.
OmegaConf.load, converting a YAML syntax error into a clean ConfigError naming file + line/column.
FileNotFoundError is left to propagate so callers can report a missing-path error themselves.
Return nemo-gym’s own openai requirement string (name plus specifier, as declared in its metadata).
Returns None when the requirement cannot be determined (nemo-gym not
installed as a distribution, packaging unavailable, only marker’d
requirements found).
True when version satisfies nemo-gym’s own openai requirement.
head_server_deps normally pins the parent process’s openai version into every sub-venv for consistency. When the parent environment ships an openai release outside nemo-gym’s own constraint (e.g. the base image preinstalls a newer openai than nemo-gym’s cap allows), that pin makes every sub-venv resolution unsatisfiable — and the dry-run prefetch then bakes venvs that contain nothing but pip. The parser uses this to fail fast (or, with the explicit opt-in, to fall back to nemo-gym’s own resolution) instead of emitting an impossible pin. Returns True (preserving the original pin-the-parent behavior) when the constraint cannot be determined.
Invert the agent -> resources_server edges of a merged config.
Returns {resources server instance name: [agent instance names referencing it]}. This is the
lookup that routes task_source-stamped rows to an agent (and, transitionally, lets collate
dual-stamp a legacy agent_ref). Template placeholders (name: ???) and malformed blocks are
skipped: they are not routable candidates.
The agent types resources_server_name declares support for, or None when it declares none.
A bare string is accepted as a single entry: an ++...allowed_agents=name override arrives before the
server model is validated, and iterating it would read the name as its characters.
Format user-friendly warning. Union literal errors are consolidated.
Union discriminator noise is filtered out. Explanation:
Pydantic validation is quirky- it will report all failures in the union if any union member fails. Example:
If an agent server contains an invalid license, it will not only show the error for the invalid license in ResponsesAPIAgentServerInstanceConfig, but also missing values for ResponsesAPIModelServerInstanceConfig responses_api_models and ResourcesServerInstanceConfig resources_servers.
This function provides a handle to the global configuration dict global_config_dict. We try to have one source of truth for everything in NeMo gym.
This config is resolved once and only once, immediately on a run command.
On first initialization, the global config dict will be loaded from the following sources in order of priority (later items are higher priority):
- Configuration yamls specified in
config_pathsparameter. - Configuration (usually sensitive values like API keys, etc) from a local
.env.yamlfile. - Command line argument configuration.
Validation is performed on the passed in configs:
- If a host or port is not provided for a server, defaults will be provided. Ports are resolved by the OS.
- If there are server reference configs, the respective server names and types will be validated against the remainder of the config.
Then, the global config dict will be cached and reused.
If this function is run by a child server of the main proc, that child will have been spun up with an environment variable with key NEMO_GYM_CONFIG_DICT_ENV_VAR_NAME. The config dict will be read directly off this variable, cached, and returned with no additional validation.
The global config dict when this process already has one; never triggers a CLI parse.
Returns the cached dict, or the one the parent injected via
NEMO_GYM_CONFIG_DICT (caching it), or None in a bare process. Library code
that only wants to consult the config should use this instead of
get_global_config_dict, which falls through to a full CLI/hydra parse.
True when the allowed_agents guard has been waived by config key or environment variable.