Apalis

Table of Contents

Previous topic

Functions

Next topic

apalis.Handler

Classes

The Handler and GroupHandler classes can be used to parallelize objects in python. For examples on how to use the classes see this Jupyter Notebook.

If you are unsure which class to use it is recommended to use the Handler class. The Handler class is easier to work with and as fast as the GroupHandler class if the number of objects that need to be parallelized is less or equal than the number of cores in your CPU.

If you want to parallelize more objects than the number of your CPU cores I recommend using the GroupHandler class. It will distribute your objects onto as many processes as CPU cores you have on your machine. In the image bellow, the Handler and GroupHandler are compared for workloads where 32 objects are parallelized on a 16 core CPU. Different tasks that take different time t_{single} are parallelized by both Handler and GroupHandler.

_images/timings_37_0.png

The image was generated by this Jupyter Notebook. Note that the longer the task takes the closer to 16 times improvement we get.

Decorators

class apalis.RemoteClass(clas)

Objects of classes decorated with RemoteClass will be initialized in a seperate process.

Methods

__call__(*args, **kwargs)

Call self as a function.

Shared Objects

class apalis.SharedArray(x)

Creates a new shared numpy array from an existing ndarray. SharedArrays can be used the same way as the usual numpy arrays. Note that when a SharedArray is send to another process through multiprocessing the array is not copied.

Parameters
npnumpy.ndarray

Numpy array to be saved into shared memory.

Examples

>>> a = apalis.SharedArray(np.zeros(10))
SharedArray([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
>>> a.unlink()

Methods

unlink()

Deletes the object from shared memory.

Deletes the object from shared memory.