Skip to navigation

nemo_gym.cli.env

View as MarkdownOpen in Claude

Module Contents

Classes

NameDescription
InitEnvironmentConfig-
ManifestCommandConfig-
PipListConfig-
RunConfigStart NeMo Gym servers for agents, models, and resources.
SchemaConfigPrint a resources server’s task-data schema as JSON Schema.
ServerConfigProblemA server block value that its server’s config class rejects, or a block that could not be checked.
TestAllConfigRun tests for all server modules in the project.
TestConfigTest a specific server module by running its pytest suite and optionally validating example data.

Functions

NameDescription
_catalog_payload-
_check_environment_server_configsValidate each Environment Server block against its server’s config class without starting it.
_command_overridesParse the already-translated local command flags without resolving Gym runtime config.
_compose_for_validationCompose the config as gym eval run does from the same run args; the job adds the policy model itself.
_composition_failureWhy the config did not compose, and the key whose value did not resolve when the error names one.
_delete_server_venv-
_display_list_of_paths-
_entry_serversThe resources server and agent an entry runs with, as the catalog views show them.
_entrypoint_config_classThe config class of the server an entrypoint runs, the one its launch validates its block against.
_env_or_job_time_valueoc.env that reads an unset variable without a default as a job-time value.
_format_pct-
_inspect_environmentRender one entry from the unified environment catalog.
_manifest_entry-
_print_validation_report-
_reject_manifest_command_extras-
_run_manifest_verifier-
_select_shardDeterministically select this shard’s subset of modules.
_setup_allInstall every selected server’s venv the way the suite would, then exit non-zero if any failed.
_setup_singleInstall one server’s venv exactly as _test_single does, without running its tests.
_test_single-
_validate_data_single-
_validate_server_typesgym env validate --server-types: print one finding per line; return 0, 1, 2, or 3 for a crash.
dump_configDisplay the resolved Hydra configuration for debugging purposes.
init_environmentCreate a manifest-backed environment or benchmark skeleton.
init_resources_serverInitialize a new resources server with template files and directory structure.
list_environmentsList or inspect the manifest and legacy environment/benchmark catalog.
pip_listList packages installed in a server’s virtual environment.
prefetchPre-warm per-server venvs without starting any servers.
publish_environment_manifestRun local publication checks and confirm a workload is cataloged.
runStart NeMo Gym servers for agents, models, and resources.
show_schemaPrint the selected server’s TaskData schema (see nemo_gym/data/task_data.py).
status-
test-
test_all-
test_environment_manifestExercise a manifest-backed workload’s verifier fixture without starting services.
validateValidate a manifest-backed workload or a legacy Gym config without starting services.
validate_server_configsValidate each server block of the given server types against its own server’s config class, starting nothing.

Data

JOB_TIME_VALUE

_JOB_TIME_VALUE_ROUNDS

_MANIFEST_PUBLISH_KEYS

_MANIFEST_TEST_KEYS

_MANIFEST_VALIDATE_KEYS

_NO_DEFAULT

__getattr__

API

class nemo_gym.cli.env.InitEnvironmentConfig()

Bases: BaseNeMoGymCLIConfig

higher_is_better
Optional[bool] = None
profile
IntegrationProfile = IntegrationProfile.CUSTOM_GYM_VERIFIER
reuse_verifier
Optional[str] = None
reward_range
Optional[Tuple[float, float]] = None
scaffold_kind
EnvironmentKind
scaffold_name
str
class nemo_gym.cli.env.ManifestCommandConfig()

Bases: BaseNeMoGymCLIConfig

catalog_kind
Optional[EnvironmentKind] = None
manifest_path
Optional[Path] = None
onboarding_name
Optional[str] = None
sync
bool = False
update_expected
bool = False
class nemo_gym.cli.env.PipListConfig()

Bases: RunConfig

format
Optional[str]
outdated
bool
class nemo_gym.cli.env.RunConfig()

Bases: BaseNeMoGymCLIConfig

Start NeMo Gym servers for agents, models, and resources.

Examples:

config_paths="resources_servers/example_single_tool_call/configs/example_single_tool_call.yaml,\
responses_api_models/openai_model/configs/openai_model.yaml"
gym env start "+config_paths=[${config_paths}]"
entrypoint
str
class nemo_gym.cli.env.SchemaConfig()

Bases: RunConfig

Print a resources server’s task-data schema as JSON Schema.

Examples:

gym env schema --resources-server example_multi_step
class nemo_gym.cli.env.ServerConfigProblem()

Bases: NamedTuple

A server block value that its server’s config class rejects, or a block that could not be checked.

config_class
Optional[str] = None

The name of the config class that rejected the value; None when the block could not be checked.

message
str

The config class’s message, or why the block’s config class could not be loaded.

path
str

Dotted path in the merged config: the rejected field, else the block (or the unknown server type).

value
object = None

The rejected input, as the config class received it.

class nemo_gym.cli.env.TestAllConfig()

Bases: BaseNeMoGymCLIConfig

Run tests for all server modules in the project.

Examples:

gym env test --all
delete_venvs_after_each_test
bool
fail_on_total_and_test_mismatch
bool
num_shards
int
setup_only
bool
shard_index
int
class nemo_gym.cli.env.TestConfig()

Bases: RunConfig

Test a specific server module by running its pytest suite and optionally validating example data.

Examples:

gym env test +entrypoint=resources_servers/example_single_tool_call
_dir_path
Path
dir_path
Path
resolved_dir_path
Path

Absolute server dir resolved against the cwd, then the Gym install root.

Use this for filesystem access (reading data, running the suite); use dir_path (the relative entrypoint) for display and example commands shown to the user.

should_validate_data
bool
nemo_gym.cli.env.TestConfig.model_post_init(
context
)
nemo_gym.cli.env._catalog_payload(
) -> typing.Dict[str, object]
nemo_gym.cli.env._check_environment_server_configs(
global_config_dict: omegaconf.DictConfig
) -> typing.List[str]

Validate each Environment Server block against its server’s config class without starting it.

gym env start applies that class only when the server launches, after the other servers are up. Environment Servers ship with Gym and need few packages of their own, so this process imports their entrypoints. A server whose entrypoint does not import here is left to its launch: the returned warnings name each one.

Raises EnvironmentServerConfigError listing every invalid field, by its path in the merged config.

nemo_gym.cli.env._command_overrides() -> omegaconf.DictConfig

Parse the already-translated local command flags without resolving Gym runtime config.

nemo_gym.cli.env._compose_for_validation(
allow_job_time_values: bool,
supplied: typing.List[str]
) -> omegaconf.DictConfig

Compose the config as gym eval run does from the same run args; the job adds the policy model itself.

nemo_gym.cli.env._composition_failure(
error: BaseException
) -> typing.Dict[str, str]

Why the config did not compose, and the key whose value did not resolve when the error names one.

A failing resolver (for example oc.decode given an int) is reported at its key with the resolver’s own message. Gym’s own explanation, such as the override that supplies a missing key, is kept as it reads.

nemo_gym.cli.env._delete_server_venv(
dir_path: pathlib.Path,
global_config_dict: omegaconf.DictConfig
) -> None
nemo_gym.cli.env._display_list_of_paths(
paths: typing.List[pathlib.Path]
) -> str
nemo_gym.cli.env._entry_servers(
details: typing.Optional[typing.Dict[str, object]] = None
) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]

The resources server and agent an entry runs with, as the catalog views show them.

The manifest says when there is one. Otherwise the config’s runtime routes select the servers. A config that needs values only a run supplies, such as a judge model server, or that is malformed does not resolve; then the names written in the config file are used, each only when the file names exactly one, since a file naming several does not say which one runs. details is the config’s read_environment_details result when the caller has it.

nemo_gym.cli.env._entrypoint_config_class(
entrypoint_fpath: pathlib.Path,
module_name: str
) -> type[pydantic.BaseModel]

The config class of the server an entrypoint runs, the one its launch validates its block against.

nemo_gym.cli.env._env_or_job_time_value(
key: str,
default: object = _NO_DEFAULT
) -> typing.Optional[str]

oc.env that reads an unset variable without a default as a job-time value.

nemo_gym.cli.env._format_pct(
count: int,
total: int
) -> str
nemo_gym.cli.env._inspect_environment(
name: str,
global_config_dict: omegaconf.DictConfig
) -> None

Render one entry from the unified environment catalog.

nemo_gym.cli.env._manifest_entry(
nemo_gym.cli.env._print_validation_report(
json_output: bool
) -> None
nemo_gym.cli.env._reject_manifest_command_extras(
command_dict: omegaconf.DictConfig,
allowed: frozenset[str]
) -> None
nemo_gym.cli.env._select_shard(
dir_paths: typing.List[pathlib.Path],
shard_index: int,
num_shards: int
) -> typing.List[pathlib.Path]

Deterministically select this shard’s subset of modules.

Round-robin (stride) over a sorted list spreads heavy modules across shards more evenly than contiguous chunks, which balances wall-time when the suite is parallelized across CI runners.

nemo_gym.cli.env._setup_all(
dir_paths: typing.List[pathlib.Path],
global_config_dict: omegaconf.DictConfig
) -> None

Install every selected server’s venv the way the suite would, then exit non-zero if any failed.

The container build runs this to seed its uv cache, so scripts/ci/server_tests.sh can create the same per-server venvs offline. Every server is attempted before failing, so one run reports every gap.

nemo_gym.cli.env._setup_single(
global_config_dict: omegaconf.DictConfig
) -> subprocess.Popen

Install one server’s venv exactly as _test_single does, without running its tests.

nemo_gym.cli.env._test_single(
global_config_dict: omegaconf.DictConfig
) -> subprocess.Popen
nemo_gym.cli.env._validate_data_single(
) -> None
nemo_gym.cli.env._validate_server_types(
command_dict: omegaconf.DictConfig
) -> int

gym env validate --server-types: print one finding per line; return 0, 1, 2, or 3 for a crash.

nemo_gym.cli.env.dump_config()

Display the resolved Hydra configuration for debugging purposes.

Examples:

gym env resolve "+config_paths=[<config1>,<config2>]"
nemo_gym.cli.env.init_environment() -> None

Create a manifest-backed environment or benchmark skeleton.

nemo_gym.cli.env.init_resources_server()

Initialize a new resources server with template files and directory structure.

Examples:

gym env init --resources-server my_server
nemo_gym.cli.env.list_environments() -> None

List or inspect the manifest and legacy environment/benchmark catalog.

nemo_gym.cli.env.pip_list()

List packages installed in a server’s virtual environment.

nemo_gym.cli.env.prefetch(
global_config_dict_parser_config: typing.Optional[nemo_gym.config.global_config.GlobalConfigDictParserConfig] = None
)

Pre-warm per-server venvs without starting any servers.

Accepts the same config format as ‘gym env start’. For each server in the config, creates its isolated venv and installs dependencies serially — similar to how RL’s prefetch_venvs.py installs actor venvs at container build time.

No Ray is initialised and no server processes are started. Intended for use in Dockerfile builds so venvs are ready at runtime with no network access needed.

Configuration Parameter: config_paths (List[str]): Paths to YAML configuration files. Specify via Hydra: +config_paths="[file1.yaml,file2.yaml]"

Examples:

# Pre-warm venvs for a specific config
config_paths="responses_api_models/local_vllm_model/configs/local_vllm_model.yaml,\
resources_servers/math_with_judge/configs/math_with_judge.yaml"
gym env prefetch "+config_paths=[${config_paths}]"
nemo_gym.cli.env.publish_environment_manifest() -> None

Run local publication checks and confirm a workload is cataloged.

nemo_gym.cli.env.run(
global_config_dict_parser_config: typing.Optional[nemo_gym.config.global_config.GlobalConfigDictParserConfig] = None
)

Start NeMo Gym servers for agents, models, and resources.

This command reads configuration from YAML files specified via +config_paths and starts all configured servers. The configuration files should define server instances with their entrypoints and settings.

Configuration Parameter: config_paths (List[str]): Paths to YAML configuration files. Specify via Hydra: +config_paths="[file1.yaml,file2.yaml]"

Examples:

# Start servers with specific configs
config_paths="resources_servers/example_single_tool_call/configs/example_single_tool_call.yaml,\
responses_api_models/openai_model/configs/openai_model.yaml"
gym env start "+config_paths=[${config_paths}]"
nemo_gym.cli.env.show_schema()

Print the selected server’s TaskData schema (see nemo_gym/data/task_data.py).

nemo_gym.cli.env.status()
nemo_gym.cli.env.test()
nemo_gym.cli.env.test_all()
nemo_gym.cli.env.test_environment_manifest() -> None

Exercise a manifest-backed workload’s verifier fixture without starting services.

nemo_gym.cli.env.validate() -> None

Validate a manifest-backed workload or a legacy Gym config without starting services.

nemo_gym.cli.env.validate_server_configs(
global_config_dict: omegaconf.DictConfig,
server_types: typing.Iterable[str]

Validate each server block of the given server types against its own server’s config class, starting nothing.

Each block is checked against the class its server validates it with at launch. This process imports the entrypoint to find that class. A block whose entrypoint does not import here, for example because the server’s own venv has packages this one lacks, is one problem with config_class None, and its fields stay unchecked. A server type that Gym does not define is such a problem too, at the type’s name, so a caller written for another Gym version still gets an answer. An empty list means every checked block is valid.

nemo_gym.cli.env.JOB_TIME_VALUE = 'gym-job-time-value'
nemo_gym.cli.env._JOB_TIME_VALUE_ROUNDS = 16
nemo_gym.cli.env._MANIFEST_PUBLISH_KEYS = frozenset({'onboarding_name', 'catalog_kind', 'json', 'verbose'})
nemo_gym.cli.env._MANIFEST_TEST_KEYS = frozenset({'onboarding_name', 'catalog_kind', 'update_expected', 'json', 'verbos...
nemo_gym.cli.env._MANIFEST_VALIDATE_KEYS = frozenset({'onboarding_name', 'catalog_kind', 'manifest_path', 'sync', 'json', '...
nemo_gym.cli.env._NO_DEFAULT = object()
nemo_gym.cli.env.__getattr__ = moved_names_getattr(__name__)