ray.rllib.env.env_runner_group.EnvRunnerGroup#

class ray.rllib.env.env_runner_group.EnvRunnerGroup(*, env_creator: Callable[[EnvContext], Any | gymnasium.Env | None] | None = None, validate_env: Callable[[Any | gymnasium.Env], None] | None = None, default_policy_class: Type[Policy] | None = None, config: AlgorithmConfig | None = None, num_env_runners: int = 0, local_env_runner: bool = True, logdir: str | None = None, _setup: bool = True, tune_trial_id: str | None = None, num_workers=-1, local_worker=-1)[source]#

Set of EnvRunners with n @ray.remote workers and zero or one local worker.

Where: n >= 0.

DeveloperAPI: This API may change across minor Ray releases.

Methods

__init__

Initializes a EnvRunnerGroup instance.

add_policy

Adds a policy to this EnvRunnerGroup's workers or a specific list of workers.

add_workers

Creates and adds a number of remote workers to this worker set.

fetch_ready_async_reqs

Get esults from outstanding asynchronous requests that are ready.

foreach_env

Calls func with all workers' sub-environments as args.

foreach_env_with_context

Calls func with all workers' sub-environments and env_ctx as args.

foreach_policy

Calls func with each worker's (policy, PolicyID) tuple.

foreach_policy_to_train

Apply func to all workers' Policies iff in policies_to_train.

foreach_worker

Calls the given function with each EnvRunner as its argument.

foreach_worker_async

Calls the given function asynchronously with each worker as the argument.

foreach_worker_with_id

Calls the given function with each EnvRunner and its ID as its arguments.

get_spaces

Infer observation and action spaces from one (local or remote) EnvRunner.

healthy_worker_ids

Returns the list of remote worker IDs.

is_policy_to_train

Whether given PolicyID (optionally inside some batch) is trainable.

num_healthy_remote_workers

Returns the number of healthy remote workers.

num_healthy_workers

Returns the number of all healthy workers, including the local worker.

num_in_flight_async_reqs

Returns the number of in-flight async requests.

num_remote_env_runners

Returns the number of remote EnvRunners.

num_remote_worker_restarts

Total number of times managed remote workers have been restarted.

num_remote_workers

Returns the number of remote EnvRunners.

probe_unhealthy_workers

Checks for unhealthy workers and tries restoring their states.

reset

Hard overrides the remote EnvRunners in this set with the provided ones.

stop

Calls stop on all rollout workers (including the local one).

sync_env_runner_states

Synchronizes the connectors of this EnvRunnerGroup's EnvRunners.

sync_weights

Syncs model weights from the given weight source to all remote workers.

Attributes

local_env_runner

Returns the local EnvRunner.