nemo_gym.cli#

Module Contents#

Classes#

RunConfig

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

TestConfig

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

ServerInstanceDisplayConfig

RunHelper

TestAllConfig

Run tests for all server modules in the project.

VersionConfig

Display gym version and system information.

Functions#

_setup_env_command

_run_command

run

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

_validate_data_single

_test_single

test

_display_list_of_paths

_format_pct

test_all

dev_test

Run core NeMo Gym tests with coverage reporting (runs pytest with –cov flag).

init_resources_server

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

dump_config

Display the resolved Hydra configuration for debugging purposes.

display_help

Display a list of available NeMo Gym CLI commands.

version

Display gym version and system information.

API#

nemo_gym.cli._setup_env_command(
dir_path: pathlib.Path,
global_config_dict: omegaconf.DictConfig,
) str[source]#
nemo_gym.cli._run_command(
command: str,
working_dir_path: pathlib.Path,
) subprocess.Popen[source]#
class nemo_gym.cli.RunConfig(/, **data: typing.Any)[source]#

Bases: nemo_gym.config_types.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"
ng_run "+config_paths=[${config_paths}]"

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

entrypoint: str#

‘Field(…)’

class nemo_gym.cli.TestConfig(/, **data: typing.Any)[source]#

Bases: nemo_gym.cli.RunConfig

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

Examples:

ng_test +entrypoint=resources_servers/example_single_tool_call

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

should_validate_data: bool#

‘Field(…)’

_dir_path: pathlib.Path#

None

model_post_init(context)[source]#
property dir_path: pathlib.Path#
class nemo_gym.cli.ServerInstanceDisplayConfig(/, **data: typing.Any)[source]#

Bases: pydantic.BaseModel

process_name: str#

None

server_type: str#

None

name: str#

None

dir_path: pathlib.Path#

None

entrypoint: str#

None

host: Optional[str]#

None

port: Optional[int]#

None

pid: Optional[int]#

None

config_path: str#

None

url: Optional[str]#

None

class nemo_gym.cli.RunHelper[source]#
_head_server: uvicorn.Server#

None

_head_server_thread: threading.Thread#

None

_processes: Dict[str, subprocess.Popen]#

None

_server_instance_display_configs: List[nemo_gym.cli.ServerInstanceDisplayConfig]#

None

_server_client: nemo_gym.server_utils.ServerClient#

None

start(
global_config_dict_parser_config: nemo_gym.global_config.GlobalConfigDictParserConfig,
) None[source]#
display_server_instance_info() None[source]#
poll() None[source]#
wait_for_spinup() None[source]#
shutdown() None[source]#
run_forever() None[source]#
check_http_server_statuses() List[Tuple[str, nemo_gym.server_utils.ServerStatus]][source]#
nemo_gym.cli.run(
global_config_dict_parser_config: Optional[nemo_gym.global_config.GlobalConfigDictParserConfig] = None,
)[source]#

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"
ng_run "+config_paths=[${config_paths}]"
nemo_gym.cli._validate_data_single(test_config: nemo_gym.cli.TestConfig) None[source]#
nemo_gym.cli._test_single(
test_config: nemo_gym.cli.TestConfig,
global_config_dict: omegaconf.DictConfig,
) subprocess.Popen[source]#
nemo_gym.cli.test()[source]#
nemo_gym.cli._display_list_of_paths(paths: List[pathlib.Path]) str[source]#
nemo_gym.cli._format_pct(count: int, total: int) str[source]#
class nemo_gym.cli.TestAllConfig(/, **data: typing.Any)[source]#

Bases: nemo_gym.config_types.BaseNeMoGymCLIConfig

Run tests for all server modules in the project.

Examples:

ng_test_all

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

fail_on_total_and_test_mismatch: bool#

‘Field(…)’

nemo_gym.cli.test_all()[source]#
nemo_gym.cli.dev_test()[source]#

Run core NeMo Gym tests with coverage reporting (runs pytest with –cov flag).

Examples:

ng_dev_test
nemo_gym.cli.init_resources_server()[source]#

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

Examples:

ng_init_resources_server +entrypoint=resources_servers/my_server
nemo_gym.cli.dump_config()[source]#

Display the resolved Hydra configuration for debugging purposes.

Examples:

ng_dump_config "+config_paths=[<config1>,<config2>]"
nemo_gym.cli.display_help()[source]#

Display a list of available NeMo Gym CLI commands.

Examples:

ng_help
class nemo_gym.cli.VersionConfig(/, **data: typing.Any)[source]#

Bases: nemo_gym.config_types.BaseNeMoGymCLIConfig

Display gym version and system information.

Examples:

# Display version information
ng_version

# Output as JSON
ng_version +json=true

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

json_format: bool#

‘Field(…)’

nemo_gym.cli.version()[source]#

Display gym version and system information.