examples.encoders package

Subpackages

Submodules

examples.encoders.astropy_example module

A message publisher and listener for native Python objects and Astropy Tables (external plugin).

This script demonstrates the capability to transmit native Python objects and Astropy Tables using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines. By modifying the WRAPYFI_PLUGINS_PATH environment variable to include the current directory, which contains the plugins directory with astropy_tables.py file, the AstropyTable message can be used to transmit Astropy Tables.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and Astropy Tables

  • Applying the PUB/SUB pattern with mirroring

  • Using an external plugin to handle Astropy Tables

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • Astropy: Used for creating and handling astronomical tables

Install using pip:

pip install astropy

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 astropy_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 astropy_example.py --mode listen

class examples.encoders.astropy_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with Astropy Tables and other native Python objects.

examples.encoders.astropy_example.parse_args()[source]

Parse command line arguments.

examples.encoders.astropy_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.cupy_example module

A message publisher and listener for native Python objects and CuPy arrays.

This script demonstrates the capability to transmit native Python objects and CuPy arrays using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and CuPy arrays

  • Applying the PUB/SUB pattern with mirroring

  • Transmitting CuPy arrays across different devices (only GPU devices are supported)

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • CuPy: Used for handling and creating arrays with GPU acceleration (refer to https://docs.cupy.dev/en/stable/install.html for installation instructions)

Install using pip:

pip install cupy-cuda12x # Basic installation of CuPy. Replace 12x with your CUDA version e.g., cupy-cuda11x

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 cupy_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 cupy_example.py --mode listen

class examples.encoders.cupy_example.CuPyNotifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with CuPy tensors and other native Python objects.

examples.encoders.cupy_example.parse_args()[source]

Parse command line arguments.

examples.encoders.cupy_example.main(args)[source]

Main function to initiate CuPyNotifier class and communication.

examples.encoders.dask_example module

A message publisher and listener for native Python objects and Dask Arrays/Dataframes.

This script demonstrates the capability to transmit native Python objects and Dask arrays/dataframes using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and Dask arrays/dataframes

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • Dask, pandas: Used for handling and creating arrays and dataframes

Install using pip:

pip install pandas dask[complete]

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 dask_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and computes and prints the Dask objects

python3 dask_example.py --mode listen

class examples.encoders.dask_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with Dask arrays/dataframes and other native Python objects.

examples.encoders.dask_example.parse_args()[source]

Parse command line arguments.

examples.encoders.dask_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.jax_example module

A message publisher and listener for native Python objects and JAX arrays.

This script demonstrates the capability to transmit native Python objects and JAX arrays using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and JAX arrays

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • JAX: Used for handling and creating arrays (refer to https://jax.readthedocs.io/en/latest/installation.html for installation instructions)

Install using pip:

pip install jax jaxlib # Basic installation of JAX

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 jax_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 jax_example.py --mode listen

class examples.encoders.jax_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with JAX arrays and other native Python objects.

examples.encoders.jax_example.parse_args()[source]

Parse command line arguments.

examples.encoders.jax_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.mxnet_example module

A message publisher and listener for native Python objects and MXNet tensors.

This script demonstrates the capability to transmit native Python objects and MXNet tensors using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and MXNet tensors

  • Applying the PUB/SUB pattern with mirroring

  • Transmitting MXNet tensors with different contexts (CPU and GPU if available)

  • Flipping of contexts by mapping CPU to GPU and vice versa

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • MXNet: Used for handling and creating tensors (refer to https://mxnet.apache.org/get_started for installation instructions)

Install using pip:

pip install mxnet # Basic installation of MXNet

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 mxnet_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 mxnet_example.py --mode listen

class examples.encoders.mxnet_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with MXNet tensors and other native Python objects.

examples.encoders.mxnet_example.parse_args()[source]

Parse command line arguments.

examples.encoders.mxnet_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.numpy_pandas_example module

A message publisher and listener for native Python objects, NumPy Arrays, and pandas Series/Dataframes.

This script demonstrates the capability to transmit native Python objects, NumPy arrays, and pandas series/dataframes using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects, NumPy arrays, and pandas series/dataframes

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • NumPy: Used for creating arrays (installed with Wrapyfi)

  • pandas: Used for creating and handling series and dataframes

  • PyArrow: Used for compatibility with pandas>=2.0. It is not required by pandas but required for this example when installing pandas >= 2.0. Not required for pandas < 2.0.

Install using pip:

pip install "pandas<2.0" # Basic installation of pandas<2.0 with Numpy as a dependency (for compatibility) ################## OR ################## pip install "pandas>=2.0" pyarrow # Basic installation of pandas>=2.0 with PyArrow as a dependency (for compatibility)

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 numpy_pandas_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 numpy_pandas_example.py --mode listen

class examples.encoders.numpy_pandas_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with NumPy arrays, pandas series/dataframes, and other native Python objects.

examples.encoders.numpy_pandas_example.parse_args()[source]

Parse command line arguments.

examples.encoders.numpy_pandas_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.paddlepaddle_example module

A message publisher and listener for native Python objects and PaddlePaddle tensors.

This script demonstrates the capability to transmit native Python objects and PaddlePaddle tensors using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and PaddlePaddle tensors

  • Applying the PUB/SUB pattern with mirroring

  • Transmitting PaddlePaddle tensors with different devices (CPU and GPU if available)

  • Flipping of devices by mapping CPU to GPU and vice versa

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • PaddlePaddle: Used for handling and creating tensors (refer to https://www.paddlepaddle.org.cn/en/install/quick for installation instructions)

Install using pip:

pip install paddlepaddle-gpu # Basic installation of PaddlePaddle

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 paddlepaddle_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 paddlepaddle_example.py --mode listen

class examples.encoders.paddlepaddle_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with PaddlePaddle tensors and other native Python objects.

examples.encoders.paddlepaddle_example.parse_args()[source]

Parse command line arguments.

examples.encoders.paddlepaddle_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.pillow_example module

A message publisher and listener for PIL (Pillow) images.

This script demonstrates the capability to transmit native Python objects and Pillow images in different formats using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and PIL (Pillow) images

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • NumPy: Used for creating image arrays (installed with Wrapyfi)

  • PIL (Pillow): Used for handling image objects

Install using pip:

pip install pillow

Run:
# On machine 1 (or process 1): Publisher waits for keyboard and transmits message

python3 pillow_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 pillow_example.py --mode listen

class examples.encoders.pillow_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]
examples.encoders.pillow_example.parse_args()[source]

Parse command line arguments.

examples.encoders.pillow_example.main(args)[source]

Main function to initiate Notify class and communication.

examples.encoders.pint_example module

A message publisher and listener for native Python objects and Pint Quantities.

This script demonstrates the capability to transmit native Python objects and Pint Quantities using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and Pint Quantities

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • Pint: Used for handling physical quantities with units

Install using pip:

pip install pint

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 pint_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 pint_example.py --mode listen

class examples.encoders.pint_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with Pint Quantities and other native Python objects.

examples.encoders.pint_example.parse_args()[source]

Parse command line arguments.

examples.encoders.pint_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.pyarrow_example module

A message publisher and listener for native Python objects and PyArrow arrays.

This script demonstrates the capability to transmit native Python objects and PyArrow arrays using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and PyArrow arrays

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • PyArrow: Used for handling Apache Arrow arrays

Install using pip:

pip install pyarrow

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 pyarrow_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 pyarrow_example.py --mode listen

class examples.encoders.pyarrow_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with PyArrow arrays and other native Python objects.

examples.encoders.pyarrow_example.parse_args()[source]

Parse command line arguments.

examples.encoders.pyarrow_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.pytorch_example module

A message publisher and listener for native Python objects and PyTorch tensors.

This script demonstrates the capability to transmit native Python objects and PyTorch tensors using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern, allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and PyTorch tensors

  • Applying the PUB/SUB pattern with mirroring

  • Transmitting PyTorch tensors with different devices (CPU and GPU if available)

  • Flipping of devices by mapping CPU to GPU and vice versa

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • PyTorch: Used for handling and creating tensors (refer to https://pytorch.org/get-started/locally/ for installation instructions)

Install using pip:

pip install "torch>=1.12.1" # Basic installation of PyTorch

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 pytorch_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 pytorch_example.py --mode listen

class examples.encoders.pytorch_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with PyTorch tensors and other native Python objects.

examples.encoders.pytorch_example.parse_args()[source]

Parse command line arguments.

examples.encoders.pytorch_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.tensorflow_example module

A message publisher and listener for native Python objects and TensorFlow tensors.

This script demonstrates the capability to transmit native Python objects and TensorFlow tensors using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and TensorFlow tensors

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • TensorFlow: Used for creating and handling tensors (refer to https://www.tensorflow.org/install for installation instructions)

Install using pip:

pip install "tensorflow>=2.9.1" # Basic installation of TensorFlow

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 tensorflow_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 tensorflow_example.py --mode listen

class examples.encoders.tensorflow_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with TensorFlow tensors and other native Python objects.

examples.encoders.tensorflow_example.parse_args()[source]

Parse command line arguments.

examples.encoders.tensorflow_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.trax_example module

A message publisher and listener for native Python objects and Trax arrays.

This script demonstrates the capability to transmit native Python objects and Trax arrays using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and Trax arrays

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • Trax: Used for handling Google Trax arrays (refer to https://trax-ml.readthedocs.io/en/latest/notebooks/trax_intro.html for installation instructions)

Install using pip:

pip install trax

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 trax_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 trax_example.py --mode listen

class examples.encoders.trax_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with Trax arrays and other native Python objects.

examples.encoders.trax_example.parse_args()[source]

Parse command line arguments.

examples.encoders.trax_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.xarray_example module

A message publisher and listener for native Python objects and xarray DataArrays.

This script demonstrates the capability to transmit native Python objects and xarray DataArrays using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and xarray DataArrays

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • NumPy: Used for creating arrays (installed with Wrapyfi)

  • xarray, pandas: Used for creating and handling DataArrays

Install using pip:

pip install pandas xarray

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 xarray_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 xarray_example.py --mode listen

class examples.encoders.xarray_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with xarray DataArrays and other native Python objects.

examples.encoders.xarray_example.parse_args()[source]

Parse command line arguments.

examples.encoders.xarray_example.main(args)[source]

Main function to initiate Notifier class and communication.

examples.encoders.zarr_example module

A message publisher and listener for native Python objects and Zarr arrays/groups.

This script demonstrates the capability to transmit native Python objects and Zarr arrays/groups using the MiddlewareCommunicator within the Wrapyfi library. The communication follows the PUB/SUB pattern allowing message publishing and listening functionalities between processes or machines.

Demonstrations:
  • Using the NativeObject message

  • Transmitting a nested dummy Python object with native objects and Zarr arrays/groups

  • Applying the PUB/SUB pattern with mirroring

Requirements:
  • Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)

  • YARP, ROS, ROS 2, ZeroMQ (refer to the Wrapyfi documentation for installation instructions)

  • NumPy: Used for creating arrays (installed with Wrapyfi)

  • zarr: Used for creating and handling Zarr arrays and groups

Install using pip:

pip install zarr

Run:
# On machine 1 (or process 1): Publisher waits for keyboard input and transmits message

python3 zarr_example.py --mode publish

# On machine 2 (or process 2): Listener waits for message and prints the entire dummy object

python3 zarr_example.py --mode listen

class examples.encoders.zarr_example.Notifier[source]

Bases: MiddlewareCommunicator

exchange_object(mware=None)[source]

Exchange messages with Zarr arrays/groups and other native Python objects.

examples.encoders.zarr_example.parse_args()[source]

Parse command line arguments.

examples.encoders.zarr_example.main(args)[source]

Main function to initiate Notifier class and communication.

Module contents