ray.rllib.evaluation.worker_set.WorkerSet.foreach_worker
ray.rllib.evaluation.worker_set.WorkerSet.foreach_worker#
- WorkerSet.foreach_worker(func: Callable[[ray.rllib.evaluation.rollout_worker.RolloutWorker], ray.rllib.evaluation.worker_set.T], *, local_worker=True, healthy_only=False, remote_worker_ids: Optional[List[int]] = None, timeout_seconds: Optional[int] = None, return_obj_refs: bool = False, mark_healthy: bool = False) List[ray.rllib.evaluation.worker_set.T] [source]#
Calls the given function with each worker instance as the argument.
- Parameters
func – The function to call for each worker (as only arg).
local_worker – Whether apply func on local worker too. Default is True.
healthy_only – Apply func on known active workers only. By default this will apply func on all workers regardless of their states.
remote_worker_ids – Apply func on a selected set of remote workers.
timeout_seconds – Time to wait for results. Default is None.
return_obj_refs – whether to return ObjectRef instead of actual results. Note, for fault tolerance reasons, these returned ObjectRefs should never be resolved with ray.get() outside of this WorkerSet.
mark_healthy – Whether to mark the worker as healthy based on call results.
- Returns
The list of return values of all calls to
func([worker])
.