RemoteFunction

The class is a wrapper over a remote function specific for the backend. As soos as a user wraps a function with remote() decorator, the function will be an instance of RemoteFunction class. Then, the user can call the remote function using remote() method of the class.

API

class unidist.core.base.remote_function.RemoteFunction(remote_function_cls, function)

A class that is base for any remote function class specific for the backend.

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

Parameters:
  • remote_function_cls (RemoteFunction) – An instance of the child class.

  • function (callable) – A function that is meant to be remote.

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

Override the remote function invocation parameters.

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

  • num_cpus (int, optional) – Positional arguments to be overrided.

  • num_returns (int, optional) – Positional arguments to be overrided.

  • resources (int, optional) – Positional arguments to be overrided.

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

Returns:

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

Return type:

FuncWrapper

remote(*args, **kwargs)

Call a remote function in a worker process.

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

  • **kwargs (dict) – Keyword arguments to be passed in the remote function.

Return type:

ObjectRef, list or None