nemo_gym.global_config#

Module Contents#

Classes#

Functions#

get_global_config_dict

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.

set_global_config_dict

get_first_server_config_dict

find_open_port

format_almost_server_warning

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.

Data#

API#

nemo_gym.global_config._GLOBAL_CONFIG_DICT#

None

nemo_gym.global_config.NEMO_GYM_CONFIG_DICT_ENV_VAR_NAME#

‘NEMO_GYM_CONFIG_DICT’

nemo_gym.global_config.NEMO_GYM_CONFIG_PATH_ENV_VAR_NAME#

‘NEMO_GYM_CONFIG_PATH’

nemo_gym.global_config.CONFIG_PATHS_KEY_NAME#

‘config_paths’

nemo_gym.global_config.ENTRYPOINT_KEY_NAME#

‘entrypoint’

nemo_gym.global_config.DEFAULT_HOST_KEY_NAME#

‘default_host’

nemo_gym.global_config.HEAD_SERVER_KEY_NAME#

‘head_server’

nemo_gym.global_config.DISALLOWED_PORTS_KEY_NAME#

‘disallowed_ports’

nemo_gym.global_config.HEAD_SERVER_DEPS_KEY_NAME#

‘head_server_deps’

nemo_gym.global_config.PYTHON_VERSION_KEY_NAME#

‘python_version’

nemo_gym.global_config.NEMO_GYM_RESERVED_TOP_LEVEL_KEYS#

None

nemo_gym.global_config.POLICY_BASE_URL_KEY_NAME#

‘policy_base_url’

nemo_gym.global_config.POLICY_API_KEY_KEY_NAME#

‘policy_api_key’

nemo_gym.global_config.POLICY_MODEL_NAME_KEY_NAME#

‘policy_model_name’

nemo_gym.global_config.DEFAULT_HEAD_SERVER_PORT#

11000

class nemo_gym.global_config.GlobalConfigDictParserConfig#

Bases: pydantic.BaseModel

model_config#

‘ConfigDict(…)’

dotenv_path: Optional[pathlib.Path]#

None

initial_global_config_dict: Optional[omegaconf.DictConfig]#

None

skip_load_from_cli: bool#

False

skip_load_from_dotenv: bool#

False

NO_MODEL_GLOBAL_CONFIG_DICT: ClassVar[omegaconf.DictConfig]#

‘DictConfig(…)’

class nemo_gym.global_config.GlobalConfigDictParser#

Bases: pydantic.BaseModel

parse_global_config_dict_from_cli() omegaconf.DictConfig#
load_extra_config_paths(
config_paths: List[str],
) Tuple[List[str], List[omegaconf.DictConfig]]#

Returns the new total config_paths and the extra configs

filter_for_server_instance_configs(
global_config_dict: omegaconf.DictConfig,
) List[nemo_gym.config_types.ServerInstanceConfig]#
validate_and_populate_defaults(
server_instance_configs: List[nemo_gym.config_types.ServerInstanceConfig],
default_host: str,
initial_disallowed_ports: Optional[List[int]] = None,
) List[int]#
parse(
parse_config: Optional[nemo_gym.global_config.GlobalConfigDictParserConfig] = None,
) omegaconf.DictConfig#
parse_no_environment(
initial_global_config_dict: Optional[omegaconf.DictConfig] = None,
) omegaconf.DictConfig#
detect_and_report_almost_servers(
global_config_dict: omegaconf.DictConfig,
) List[Tuple[str, pydantic.ValidationError]]#
nemo_gym.global_config.get_global_config_dict(
global_config_dict_parser_config: Optional[nemo_gym.global_config.GlobalConfigDictParserConfig] = None,
global_config_dict_parser_cls: Type[nemo_gym.global_config.GlobalConfigDictParser] = GlobalConfigDictParser,
) omegaconf.DictConfig#

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):

  1. Configuration yamls specified in config_paths parameter.

  2. Configuration (usually sensitive values like API keys, etc) from a local .env.yaml file.

  3. Command line argument configuration.

Validation is performed on the passed in configs:

  1. If a host or port is not provided for a server, defaults will be provided. Ports are resolved by the OS.

  2. 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.

nemo_gym.global_config.set_global_config_dict(
global_config_dict_parser_config: Optional[nemo_gym.global_config.GlobalConfigDictParserConfig] = None,
global_config_dict_parser_cls: Type[nemo_gym.global_config.GlobalConfigDictParser] = GlobalConfigDictParser,
) None#
nemo_gym.global_config.get_first_server_config_dict(
global_config_dict: omegaconf.DictConfig,
top_level_path: str,
) omegaconf.DictConfig#
nemo_gym.global_config.find_open_port(
disallowed_ports: Optional[List[int]] = None,
max_retries: int = 50,
) int#
nemo_gym.global_config.format_almost_server_warning(
server_name: str,
error: pydantic.ValidationError,
) str#

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.