ActorClass

As soon as a user wraps a class with remote() decorator, the class will be an instance of ActorClass class. The class is a factory creating base Actor class that wraps the actor class specific for the backend when calling remote() method.

API

class unidist.core.base.actor.ActorClass(actor_cls, *actor_cls_args)

A class that serves as a actor class decorator.

This wraps an instance of the actor class, which in turn wraps an actor that is meant to be remote, specific for the backend.

Parameters:

actor_cls (Actor) – An instance of the Actor child class.

options(*args, num_cpus=None, resources=None, **kwargs)

Override the actor instantiation parameters.

Parameters:
  • *args (iterable) – Positional arguments to be overrided.

  • num_cpus (int, optional) – The number of CPUs to reserve for the lifetime of the actor.

  • resources (dict, optional) – Custom resources to reserve for the lifetime of the actor.

  • **kwargs (dict) – Keyword arguments to be overrided.

Returns:

An instance of wrapped class that a non-underscore .remote() can be called on.

Return type:

ActorWrapper

remote(*args, **kwargs)

Instantiate an actor class.

Parameters:
  • *args (iterable) – Positional arguments to be passed in the class constructor that is meant to be actor.

  • **kwargs (dict) – Keyword arguments to be passed in the class constructor that is meant to be actor.

Return type:

Actor

Actor

The class is a wrapper over an actor class specific for the backend. All calls of the methods are transmitted to the actor class of the concrete backend. The Actor implements the dunder method __getattr__() that transmits an access responsibility to the methods of the native actor for the backend, held by the concrete actor class of the backend, to ActorMethod class by calling remote() on it.

API

class unidist.core.base.actor.Actor(actor_cls)

A class that is base for any actor class specific for the backend.

This wraps an instance of the child class, which in turn wraps an actor that is meant to be remote, specific for the backend.

Parameters:

actor_cls (Actor) – An instance of the Actor child class.

ActorMethod

The class is a wrapper over an actor method class specific for the backend. All calls of the methods are transimitted to the actor class method of the concrete backend.

API

class unidist.core.base.actor.ActorMethod(actor_method_cls)

A class that is base for any actor method class specific for the backend.

This wraps an instance of the child class, which in turn wraps an actor method that is meant to be remote, specific for the backend.

Parameters:

actor_method_cls (ActorMethod) – An instance of the ActorMethod child class.

options(*args, num_returns=None, **kwargs)

Override the actor method invocation parameters.

Parameters:
  • *args (iterable) – Positional arguments to be overrided.

  • num_returns (int, optional) – The number of object refs returned by the remote function invocation.

  • **kwargs (dict) – Keyword arguments to be overrided.

Returns:

An instance of wrapped method that a non-underscore .remote() can be called on.

Return type:

FuncWrapper

remote(*args, **kwargs)

Call an actor method in a worker process.

Parameters:
  • *args (iterable) – Positional arguments to be passed in the actor method.

  • **kwargs (dict) – Keyword arguments to be passed in the actor method.

Return type:

ObjectRef, list or None