ray.rllib.core.learner.learner_group.LearnerGroup.foreach_learner#
- LearnerGroup.foreach_learner(func: Callable[[Learner, Any | None], T], *, healthy_only: bool = True, remote_actor_ids: List[int] = None, timeout_seconds: float | None = None, return_obj_refs: bool = False, mark_healthy: bool = True, **kwargs) RemoteCallResults [source]#
Calls the given function on each Learner L with the args: (L, **kwargs).
- Parameters:
func – The function to call on each Learner L with args: (L, **kwargs).
healthy_only – If True, applies
func
only to Learner actors currently tagged “healthy”, otherwise to all actors. Ifhealthy_only=False
andmark_healthy=True
, will sendfunc
to all actors and mark those actors “healthy” that respond to the request withintimeout_seconds
and are currently tagged as “unhealthy”.remote_actor_ids – Apply func on a selected set of remote actors. Use None (default) for all actors.
timeout_seconds – Time to wait (in seconds) for results. Set this to 0.0 for fire-and-forget. Set this to None (default) to wait infinitely (i.e. for synchronous execution).
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 the context of this manager.
mark_healthy – Whether to mark all those actors healthy again that are currently marked unhealthy AND that returned results from the remote call (within the given
timeout_seconds
). Note that actors are NOT set unhealthy, if they simply time out (only if they return a RayActorError). Also not that this setting is ignored ifhealthy_only=True
(b/c this setting only affects actors that are currently tagged as unhealthy).
- Returns:
A list of size len(Learners) with the return values of all calls to
func
.