Skip to navigation

nemo_gym.utils.server_process

View as MarkdownOpen in Claude

Whether this process is a Gym server worker, and the environment variables that tell it.

The main server process sets these variables before uvicorn starts its workers, so each worker knows its role and the entrypoint it serves.

Module Contents

Functions

Data

IS_NEMO_GYM_FASTAPI_ENTRYPOINT_KEY_NAME

IS_NEMO_GYM_FASTAPI_WORKER_KEY_NAME

NEMO_GYM_FASTAPI_NUM_WORKERS

API

nemo_gym.utils.server_process._has_injected_global_config_env() -> bool
nemo_gym.utils.server_process.get_nemo_gym_fastapi_num_workers() -> int
nemo_gym.utils.server_process.is_nemo_gym_fastapi_entrypoint(
file: str
) -> bool

Whether the module calling this, defined in file, is the entrypoint this worker serves.

uvicorn starts each worker with the spawn method. Spawn first re-runs the parent’s main script under the name __mp_main__, and only then does uvicorn import the entrypoint by module name and serve its app. Gym starts a server by running its entrypoint as the main script, so the __mp_main__ copy is that same file. This returns False for that copy. Otherwise each worker would build the server twice: once in the copy, which nothing serves, before uvicorn’s health check starts answering, and once for the app it serves.

nemo_gym.utils.server_process.is_nemo_gym_fastapi_worker() -> bool
nemo_gym.utils.server_process.set_is_nemo_gym_fastapi_entrypoint(
file: str
) -> None
nemo_gym.utils.server_process.set_is_nemo_gym_fastapi_worker() -> None
nemo_gym.utils.server_process.set_nemo_gym_fastapi_num_workers(
num_workers: int
) -> None
nemo_gym.utils.server_process.IS_NEMO_GYM_FASTAPI_ENTRYPOINT_KEY_NAME = 'IS_NEMO_GYM_FASTAPI_ENTRYPOINT'
nemo_gym.utils.server_process.IS_NEMO_GYM_FASTAPI_WORKER_KEY_NAME = 'IS_NEMO_GYM_FASTAPI_WORKER'
nemo_gym.utils.server_process.NEMO_GYM_FASTAPI_NUM_WORKERS = 'NEMO_GYM_FASTAPI_NUM_WORKERS'