nemo_gym.cli.env

View as Markdown

Module Contents

Classes

NameDescription
PipListConfig-
RunConfigStart NeMo Gym servers for agents, models, and resources.
RunHelper-
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
_display_list_of_paths-
_format_pct-
_resolve_server_dirResolve a relative server dir (e.g. resources_servers/<name>) to an absolute path.
_select_shardDeterministically select this shard’s subset of modules.
_test_single-
_validate_data_single-
dump_configDisplay the resolved Hydra configuration for debugging purposes.
exit_cleanly_on_config_errorDecorator: turn user-facing ConfigError into a clean message + non-zero exit.
init_resources_serverInitialize a new resources server with template files and directory structure.
list_environmentsList the environments available under environments/, by short name.
pip_listList packages installed in a server’s virtual environment.
runStart NeMo Gym servers for agents, models, and resources.
status-
test-
test_all-
validateValidate a config without starting Ray or any server subprocess.

Data

_FORCE_KILL_REAP_TIMEOUT_SEC

_GRACEFUL_SHUTDOWN_TIMEOUT_SEC

API

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.RunHelper()
_head_server
Server
_head_server_instance
HeadServer
_head_server_thread
Thread
_processes
Dict[str, Popen]
_server_client
ServerClient
_server_instance_display_configs
List[ServerInstanceDisplayConfig]
nemo_gym.cli.env.RunHelper.check_http_server_statuses(
successful_servers: typing.List[str]
) -> typing.List[typing.Tuple[str, nemo_gym.server_utils.ServerStatus]]
nemo_gym.cli.env.RunHelper.display_server_instance_info() -> None
nemo_gym.cli.env.RunHelper.poll() -> None
nemo_gym.cli.env.RunHelper.run_forever() -> None
nemo_gym.cli.env.RunHelper.shutdown() -> None
nemo_gym.cli.env.RunHelper.start(
global_config_dict_parser_config: nemo_gym.global_config.GlobalConfigDictParserConfig
) -> None
nemo_gym.cli.env.RunHelper.wait_for_dry_run_spinup() -> None
nemo_gym.cli.env.RunHelper.wait_for_spinup() -> None
class nemo_gym.cli.env.TestAllConfig()

Bases: BaseNeMoGymCLIConfig

Run tests for all server modules in the project.

Examples:

gym env test
delete_venvs_after_each_test
bool
fail_on_total_and_test_mismatch
bool
num_shards
int
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._display_list_of_paths(
paths: typing.List[pathlib.Path]
) -> str
nemo_gym.cli.env._format_pct(
count: int,
total: int
) -> str
nemo_gym.cli.env._resolve_server_dir(
rel_path: pathlib.Path
) -> pathlib.Path

Resolve a relative server dir (e.g. resources_servers/<name>) to an absolute path.

Checks the current working directory first (a user’s local server), then falls back to the Gym install root (PARENT_DIR) where built-in servers live in both editable and wheel installs. This lets gym env test find and run built-in servers from any cwd, not just a repo checkout.

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._test_single(
test_config: nemo_gym.cli.env.TestConfig,
global_config_dict: omegaconf.DictConfig
) -> subprocess.Popen
nemo_gym.cli.env._validate_data_single(
test_config: nemo_gym.cli.env.TestConfig
) -> None
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.exit_cleanly_on_config_error(
fn
)

Decorator: turn user-facing ConfigError into a clean message + non-zero exit.

Config mistakes (missing/typo’d config_paths, malformed config_paths, nothing configured to run) should fail fast with an actionable message, not a Python traceback. Unexpected errors still propagate normally.

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 the environments available under environments/, by short name.

Examples:

gym list environments
gym list environments --json
nemo_gym.cli.env.pip_list()

List packages installed in a server’s virtual environment.

nemo_gym.cli.env.run(
global_config_dict_parser_config: typing.Optional[nemo_gym.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.

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.status()
nemo_gym.cli.env.test()
nemo_gym.cli.env.test_all()
nemo_gym.cli.env.validate()

Validate a config without starting Ray or any server subprocess.

Runs the full config parse — config_paths resolution (missing/malformed), server cross-reference validation, mandatory ??? values, and schema — then exits 0 (valid) or, via exit_cleanly_on_config_error, 1 with a clean traceback-free message. No Ray, no servers, so it returns in well under a second instead of after Ray bootstrap.

No model config is required: a dummy policy_model is injected (the NO_MODEL parser config, as in gym list / env compose) so model interpolations (e.g. $&#123;policy_base_url&#125;) resolve — validation is about config well-formedness, not the model. Pass a model config / --model-type as well if you want it validated too.

Examples:

gym env validate --environment <env>
gym env validate --benchmark <benchmark>
# or by explicit config path(s):
gym env validate --config resources_servers/<env>/configs/<env>.yaml
nemo_gym.cli.env._FORCE_KILL_REAP_TIMEOUT_SEC: int = 2
nemo_gym.cli.env._GRACEFUL_SHUTDOWN_TIMEOUT_SEC: int = 1