[docs] 3classLabelledActor(): 4"""A ray actor that can execute the function `func` along with a label to 5 allow an ordering of calls to be re-established. Additionally, as the actor 6 stores `func` so that copying of `func` only occurs on initialisation opposed 7 to every call of `func`. 8 """
[docs] 9def__init__(self,func:Callable):10"""Initialises a :class:`LabelledActor`1112 Parameters13 ----------14 func : Callable15 The function saved by the actor.16 """17self._func=func
[docs]18defrun(self,19label:Any,20*args:Any21)->Tuple[Any,Any]:22"""A wrapping that allows labelled execution of the function.2324 Parameters25 ----------26 label : Any27 The label assigned to the execution.28 *args : Any29 The arguments to pass to the stored function `func`.3031 Returns32 -------33 Tuple[Any, Any]34 The label followed by the return of `func`.35 """36returnlabel,self._func(*args)
[docs]37defset_func(self,func:Callable):38"""Updates the function `func` stored by the actor.3940 Parameters41 ----------42 func : Callable43 The new function.44 """45self._func=func
[docs]46defget_func(self)->Callable:47"""Gets the function `func` stored by the actor.4849 Returns50 -------51 Callable52 The stored function.53 """54returnself._func