Skip to navigation

nemo_gym.server_runtime.ray_support

View as Markdown

Ray support for Gym servers: detecting Ray, starting or joining a cluster, and shutting down a cluster Gym started.

Module Contents

Functions

NameDescription
_connect_server_to_rayJoin the run’s Ray cluster if this server declares that it uses Ray.
_declared_ray_enabledThe literal ray_enabled assigned in a class body, or None when there is none.
_get_rayImport Ray only for processes configured to use it.
entrypoint_ray_enabledThe ray_enabled declaration of the server an entrypoint starts, read from source.
initialize_rayInitialize ray cluster in a process.
maybe_ray_cluster_exit-
ray_is_installedWhether Ray can be imported in this process, checked without importing it.

Data

_NEMO_GYM_STARTED_RAY_CLUSTER

API

nemo_gym.server_runtime.ray_support._connect_server_to_ray(
server_class: type,
global_config_dict: omegaconf.DictConfig
) -> None

Join the run’s Ray cluster if this server declares that it uses Ray.

nemo_gym.server_runtime.ray_support._declared_ray_enabled(
class_node: ast.ClassDef
) -> bool | None

The literal ray_enabled assigned in a class body, or None when there is none.

nemo_gym.server_runtime.ray_support._get_ray()

Import Ray only for processes configured to use it.

nemo_gym.server_runtime.ray_support.entrypoint_ray_enabled(
entrypoint_fpath: pathlib.Path
) -> bool | None

The ray_enabled declaration of the server an entrypoint starts, read from source.

The supervisor must decide whether to start Ray before any server exists; see entrypoint_class_flag for what the source alone can settle.

nemo_gym.server_runtime.ray_support.initialize_ray() -> None

Initialize ray cluster in a process. We store the Ray address in the global config dict so that child processes can connect to it. This avoids the need to start a new Ray cluster in each child process. Note: This function will modify the global config dict - update ray_head_node_address

nemo_gym.server_runtime.ray_support.maybe_ray_cluster_exit()
nemo_gym.server_runtime.ray_support.ray_is_installed() -> bool

Whether Ray can be imported in this process, checked without importing it.

nemo_gym.server_runtime.ray_support._NEMO_GYM_STARTED_RAY_CLUSTER: bool = False