helios.layouts.ipc_tools

Inter-Process communication tools

This Module provides abstract classes and objects to deal with inter-process communication.

References

[1]“Python GSoC - Post #3: Network layout algorithms using IPC - demvessias’s Blog.” blogs.python-gsoc.org/en/demvessiass-blog/post-3 (accessed Jul. 24, 2021).

GenericArrayBufferManager

class helios.layouts.ipc_tools.GenericArrayBufferManager(dimension, dtype='float64', num_elements=None)[source]

Bases: abc.ABC

This implements a abstract (generic) ArrayBufferManager.

The GenericArrayBufferManager is used for example to share the positions, edges and weights between different process.

Parameters
  • dimension (int) –

  • dtype (dtype) –

  • num_elements (int, optional) – In MacOs a shared memory resource can be created with a different number of elements then the original data

SharedMemArrayManager

class helios.layouts.ipc_tools.SharedMemArrayManager(dimension, dtype, data=None, buffer_name=None, num_elements=None)[source]

Bases: helios.layouts.ipc_tools.GenericArrayBufferManager

An implementation of a GenericArrayBufferManager using SharedMemory

Parameters
  • dimension (int) – number of columns

  • dtype (str) – type of the ndarray

  • data (ndarray) – bi-dimensional array

  • buffer_name (str) – buffer_name, if you pass that, then this Obj. will try to load the memory resource

  • num_elements (int, optional) – In MacOs a shared memory resource can be created with a different number of elements then the original data

ShmManagerMultiArrays

class helios.layouts.ipc_tools.ShmManagerMultiArrays[source]

Bases: object

This Obj. allows to deal with multiple arrays stored using SharedMemory

add_array(attr_name, data, dimension, dtype)[source]

This creates a shared memory resource to store the data.

The shared memory obj will be accessible through

>>> self.attr_name
Parameters
  • attr_name (str) – used to associate a new attribute ‘attr_name’ with the current (self) ShmManagerMultiArrays.

  • data (ndarray) –

  • dimension (int) –

  • dtype (str) –

load_array(attr_name, buffer_name, dimension, dtype, num_elements=None)[source]

This will load the shared memory resource associate with buffer_name into the current ShmManagerMultiArrays The shared memory obj will be accessible through

>>> self.attr_name
Parameters
  • attr_name (str) – this name will be used to associate a new attribute ‘attr_name’ with the current (self) ShmManagerMultiArrays.

  • buffer_name (str) –

  • dimension (int) –

  • dtype (str) –

  • num_elements (int, optional) – In MacOs a shared memory resource can be created with a different number of elements then the original data