wrapyfi.plugins package
Submodules
wrapyfi.plugins.cupy_array module
Encoder and Decoder for CuPy Array Data via Wrapyfi.
This script provides mechanisms to encode and decode CuPy array data using Wrapyfi. It leverages base64 encoding to convert binary data into ASCII strings.
The script contains a class, CuPyArray, registered as a plugin to manage the conversion of CuPy array data (if available) between its original and encoded forms. CuPy only supports GPU devices, specifically NVIDIA CUDA devices. Installing CUDA Toolkit (https://developer.nvidia.com/cuda-toolkit) is required to use CuPy.
Requirements: - Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions) - CuPy: A GPU-accelerated library for numerical computations with a NumPy-compatible interface (refer to https://docs.cupy.dev/en/stable/install.html for installation instructions) Note: If CuPy is not available, HAVE_CUPY will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install cupy-cuda12x
# Basic installation of CuPy. Replace 12x with your CUDA version e.g., cupy-cuda11x
- wrapyfi.plugins.cupy_array.cupy_device_to_str(device)[source]
Convert a CuPy device to a string representation.
- Parameters:
device – Union[cupy.cuda.Device, int]: The CuPy device
- Returns:
str: A string representing the CuPy device
- wrapyfi.plugins.cupy_array.cupy_str_to_device(device_str)[source]
Convert a string to a CuPy device.
- Parameters:
device_str – str: A string representing a CuPy device
- Returns:
cupy.cuda.Device: A CuPy device
- class wrapyfi.plugins.cupy_array.CuPyArray(load_cupy_device=None, map_cupy_devices=None, **kwargs)[source]
Bases:
Plugin
- __init__(load_cupy_device=None, map_cupy_devices=None, **kwargs)[source]
Initialize the CuPy plugin.
- Parameters:
load_cupy_device – cupy.cuda.Device or str: Default CuPy device to load tensors onto
map_cupy_devices – dict: [Optional] A dictionary mapping encoded device strings to decoding devices
wrapyfi.plugins.dask_data module
Encoder and Decoder for Dask Arrays/Dataframes Data via Wrapyfi.
This script provides mechanisms to encode and decode Dask data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings.
The script contains a class, DaskData, registered as a plugin to manage the conversion of Dask data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
Dask: A flexible library for parallel computing in Python (refer to https://docs.dask.org/en/latest/install.html for installation instructions)
- pandas: A data structures library for data analysis, time series, and statistics (refer to https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html for installation instructions)
Note: If Dask or pandas is not available, HAVE_DASK will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install pandas dask[complete]
# Basic installation of Dask and pandas
- class wrapyfi.plugins.dask_data.DaskData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode Dask data into a base64 ASCII string.
- Parameters:
obj – Union[dd.DataFrame, dd.Series, da.Array]: The Dask data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and object type
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into Dask data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and object type
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Union[dd.DataFrame, dd.Series, da.Array]]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Union[dd.DataFrame, da.Array]: The decoded Dask data
wrapyfi.plugins.jax_tensor module
Encoder and Decoder for JAX Tensor Data via Wrapyfi.
This script provides mechanisms to encode and decode JAX tensor data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings.
The script contains a class, JAXTensor, registered as a plugin to manage the conversion of JAX tensor data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- JAX: An open-source high-performance machine learning library (refer to https://github.com/google/jax for installation instructions)
Note: If JAX is not available, HAVE_JAX will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install jax jaxlib
# Basic installation of JAX
- class wrapyfi.plugins.jax_tensor.JAXTensor(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode JAX tensor data into a base64 ASCII string.
- Parameters:
obj – jax.numpy.DeviceArray: The JAX tensor data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name and encoded data string
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into JAX tensor data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, jax.numpy.DeviceArray]: A tuple containing: - bool: Always True, indicating that the decoding was successful - jax.numpy.DeviceArray: The decoded JAX tensor data
wrapyfi.plugins.mxnet_tensor module
Encoder and Decoder for MXNet Tensor Data via Wrapyfi.
This script provides mechanisms to encode and decode MXNet tensor data using Wrapyfi. It leverages base64 encoding to convert binary data into ASCII strings.
The script contains a class, MXNetTensor, registered as a plugin to manage the conversion of MXNet tensor data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- MXNet: A deep learning framework designed for both efficiency and flexibility (refer to https://mxnet.apache.org/get_started for installation instructions)
Note: If MXNet is not available, HAVE_MXNET will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install mxnet
# Basic installation of MXNet
- wrapyfi.plugins.mxnet_tensor.mxnet_device_to_str(device)[source]
Convert an MXNet device to a string representation.
- Parameters:
device – Union[str, mxnet.Context, dict]: Various possible types representing an MXNet device as mxnet.Context or str. Also accepts a dictionary mapping encoded device strings to decoding devices
- Returns:
Union[str, dict]: A string or dictionary representing the MXNet device
- wrapyfi.plugins.mxnet_tensor.mxnet_str_to_device(device)[source]
Convert a string to an MXNet device.
- Parameters:
device – str: A string representing an MXNet device
- Returns:
mxnet.Context: An MXNet context representing the device
- class wrapyfi.plugins.mxnet_tensor.MXNetTensor(load_mxnet_device=None, map_mxnet_devices=None, **kwargs)[source]
Bases:
Plugin
- __init__(load_mxnet_device=None, map_mxnet_devices=None, **kwargs)[source]
Initialize the MXNetTensor plugin.
- Parameters:
load_mxnet_device – Union[mxnet.Context, str]: Default MXNet device to load tensors onto
map_mxnet_devices – dict: [Optional] A dictionary mapping encoded device strings to decoding devices
- encode(obj, *args, **kwargs)[source]
Encode MXNet tensor data into a base64 ASCII string.
- Parameters:
obj – mxnet.nd.NDArray: The MXNet tensor data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and device string.
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into MXNet tensor data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and device string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, mxnet.nd.NDArray]: A tuple containing: - bool: Always True, indicating that the decoding was successful - mxnet.nd.NDArray: The decoded MXNet tensor data
wrapyfi.plugins.paddle_tensor module
Encoder and Decoder for PaddlePaddle Tensor Data via Wrapyfi.
This script provides mechanisms to encode and decode PaddlePaddle tensor data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings.
The script contains a class, PaddleTensor, registered as a plugin to manage the conversion of PaddlePaddle tensor data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- PaddlePaddle: An open-source deep learning platform developed by Baidu (refer to https://www.paddlepaddle.org.cn/en/install/quick for installation instructions)
Note: If PaddlePaddle is not available, HAVE_PADDLE will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install paddlepaddle-gpu<2.6.0
# Basic installation of PaddlePaddle
- wrapyfi.plugins.paddle_tensor.paddle_device_to_str(device)[source]
Convert a PaddlePaddle device to a string representation.
- Parameters:
device – Union[str, paddle.fluid.libpaddle.Place, dict]: Various possible types representing a PaddlePaddle device
- Returns:
Union[str, dict]: A string or dictionary representing the PaddlePaddle device
- wrapyfi.plugins.paddle_tensor.paddle_str_to_device(device)[source]
Convert a string to a PaddlePaddle device.
- Parameters:
device – str: A string representing a PaddlePaddle device
- Returns:
paddle.fluid.libpaddle.Place: A PaddlePaddle place representing the device
- class wrapyfi.plugins.paddle_tensor.PaddleTensor(load_paddle_device=None, map_paddle_devices=None, **kwargs)[source]
Bases:
Plugin
- __init__(load_paddle_device=None, map_paddle_devices=None, **kwargs)[source]
Initialize the PaddleTensor plugin.
- Parameters:
load_paddle_device – Union[paddle.fluid.libpaddle.Place, str]: Default PaddlePaddle device to load tensors onto
map_paddle_devices – dict: A dictionary mapping encoded device strings to decoding devices
- encode(obj, *args, **kwargs)[source]
Encode PaddlePaddle tensor data into a base64 ASCII string.
- Parameters:
obj – paddle.Tensor: The PaddlePaddle tensor data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and device string
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into PaddlePaddle tensor data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and device string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, paddle.Tensor]: A tuple containing: - bool: Always True, indicating that the decoding was successful - paddle.Tensor: The decoded PaddlePaddle tensor data
wrapyfi.plugins.pandas_data module
Encoder and Decoder for pandas Series/Dataframes Data via Wrapyfi.
This script provides mechanisms to encode and decode pandas data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings for “pandas<2.0”. It utilizes base64 encoding and pickle serialization for “pandas>=2.0”.
The script contains a class, PandasData, registered as a plugin to manage the conversion of pandas data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- pandas: A data structures library for data analysis, time series, and statistics (refer to https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html for installation instructions)
Note: If pandas is not available, HAVE_PANDAS will be set to False and the plugin will be registered with no types. For pandas>=2.0, the object is pickled (slower but identical on decoding). For pandas<2.0, the object is encoded using base64 (faster but potentially non-identical on decoding).
- You can install the necessary packages using pip:
pip install pandas
# Basic installation of pandas
- class wrapyfi.plugins.pandas_data.PandasData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode pandas data using pickle and base64.
- Parameters:
obj – Union[pandas.DataFrame, pandas.Series]: The pandas data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, pickled data string, and any buffer data
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a pickled and base64 encoded string back into pandas data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the pickled data string and any buffer data
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Union[pandas.DataFrame, pandas.Series]]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Union[pandas.DataFrame, pandas.Series]: The decoded pandas data
- class wrapyfi.plugins.pandas_data.PandasLegacyData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode pandas data into a base64 ASCII string.
- Parameters:
obj – Union[pandas.DataFrame, pandas.Series]: The pandas data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and object type
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into pandas data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and object type
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Union[pandas.DataFrame, pandas.Series]]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Union[pandas.DataFrame, pandas.Series]: The decoded pandas data
wrapyfi.plugins.pillow_image module
Encoder and Decoder for PIL Image Data via Wrapyfi.
This script provides mechanisms to encode and decode PIL Image data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings, and also handles non-ASCII encodings for certain image formats.
The script contains a class, PILImage, registered as a plugin to manage the conversion of PIL Image data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- PIL (Pillow): A Python Imaging Library that adds image processing capabilities to your Python interpreter (refer to https://pillow.readthedocs.io/en/stable/installation.html for installation instructions)
Note: If PIL is not available, HAVE_PIL will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install Pillow
# Basic installation of Pillow (PIL Fork)
- class wrapyfi.plugins.pillow_image.PILImage(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode PIL Image data into a base64 ASCII string.
- Parameters:
obj – Image.Image: The PIL Image data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name and encoded data string, with optional image size and mode for raw data
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into PIL Image data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and optionally image size and mode for raw data
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Image.Image]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Image.Image: The decoded PIL Image data
wrapyfi.plugins.pint_quantities module
Encoder and Decoder for Pint Quantity Data via Wrapyfi.
This script provides mechanisms to encode and decode Pint Quantity Data using Wrapyfi. It utilizes base64 encoding and JSON serialization.
The script contains a class, PintData, registered as a plugin to manage the conversion of Pint Quantity data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- Pint: A package to define, operate and manipulate physical quantities (refer to https://pint.readthedocs.io/en/stable/ for installation instructions)
Note: If Pint is not available, HAVE_PINT will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install pint
# Basic installation of Pint
- class wrapyfi.plugins.pint_quantities.PintData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode Pint Quantity data into a base64 ASCII string.
- Parameters:
obj – pint.Quantity: The Pint Quantity data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and object type
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into Pint Quantity data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and object type
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, pint.Quantity]: A tuple containing: - bool: Indicating that the decoding was successful - pint.Quantity: The decoded Pint Quantity data
wrapyfi.plugins.pyarrow_array module
Encoder and Decoder for PyArrow StructArray Data via Wrapyfi.
This script provides mechanisms to encode and decode PyArrow StructArray Data using Wrapyfi. It utilizes base64 encoding and pickle serialization.
The script contains a class, PyArrowArray, registered as a plugin to manage the conversion of PyArrow StructArray data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- PyArrow: A cross-language development platform for in-memory data (refer to https://arrow.apache.org/install/ for installation instructions)
Note: If PyArrow is not available, HAVE_PYARROW will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install pyarrow
# Basic installation of PyArrow
- class wrapyfi.plugins.pyarrow_array.PyArrowArray(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode PyArrow StructArray data using pickle and base64.
- Parameters:
obj – pa.StructArray: The PyArrow StructArray data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, pickled data string, and any buffer data
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a pickled and base64 encoded string back into PyArrow StructArray data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the pickled data string and any buffer data
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, pa.StructArray]: A tuple containing: - bool: Always True, indicating that the decoding was successful - pa.StructArray: The decoded PyArrow StructArray data
wrapyfi.plugins.pytorch_tensor module
Encoder and Decoder for PyTorch Tensor Data via Wrapyfi.
This script provides mechanisms to encode and decode PyTorch tensor data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings.
The script contains a class, PytorchTensor, registered as a plugin to manage the conversion of PyTorch tensor data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- PyTorch: An open-source machine learning library developed by Facebook’s AI Research lab (refer to https://pytorch.org/get-started/locally/ for installation instructions)
Note: If PyTorch is not available, HAVE_TORCH will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install torch
# Basic installation of PyTorch
- class wrapyfi.plugins.pytorch_tensor.PytorchTensor(load_torch_device=None, map_torch_devices=None, **kwargs)[source]
Bases:
Plugin
- __init__(load_torch_device=None, map_torch_devices=None, **kwargs)[source]
Initialize the PytorchTensor plugin.
- Parameters:
load_torch_device – str: Default PyTorch device to load tensors onto
map_torch_devices – dict: A dictionary mapping encoded device strings to decoding devices
- encode(obj, *args, **kwargs)[source]
Encode PyTorch tensor data into a base64 ASCII string.
- Parameters:
obj – torch.Tensor: The PyTorch tensor data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, and device string
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into PyTorch tensor data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string and device string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, torch.Tensor]: A tuple containing: - bool: Always True, indicating that the decoding was successful - torch.Tensor: The decoded PyTorch tensor data
wrapyfi.plugins.tensorflow_tensor module
Encoder and Decoder for TensorFlow Tensor Data via Wrapyfi.
This script provides mechanisms to encode and decode TensorFlow tensor data using Wrapyfi. It utilizes base64 encoding to convert binary data into ASCII strings.
The script contains a class, TensorflowTensor, registered as a plugin to manage the conversion of TensorFlow tensor data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- TensorFlow: An end-to-end open-source platform for machine learning (refer to https://www.tensorflow.org/install for installation instructions)
Note: If TensorFlow is not available, HAVE_TENSORFLOW will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install tensorflow
# Basic installation of TensorFlow
- class wrapyfi.plugins.tensorflow_tensor.TensorflowTensor(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode TensorFlow tensor data into a base64 ASCII string.
- Parameters:
obj – tensorflow.Tensor: The TensorFlow tensor data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name and encoded data string
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a base64 ASCII string back into TensorFlow tensor data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, tensorflow.Tensor]: A tuple containing: - bool: Always True, indicating that the decoding was successful - tensorflow.Tensor: The decoded TensorFlow tensor data
wrapyfi.plugins.trax_array module
Encoder and Decoder for Trax Array Data via Wrapyfi.
This script provides mechanisms to encode and decode Trax Array Data using Wrapyfi. It utilizes base64 encoding and pickle serialization.
The script contains a class, TraxArray, registered as a plugin to manage the conversion of Trax Array data (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- Trax: A deep learning library that focuses on clear code and speed (refer to https://trax-ml.readthedocs.io/en/latest/notebooks/trax_intro.html for installation instructions)
Note: If Trax is not available, HAVE_TRAX will be set to False and the plugin will be registered with no types. Trax uses JAX or TensorFlow-NumPy as its backend, so they must be installed as well. Trax installs JAX as a dependency, but TensorFlow must be installed separately.
- You can install the necessary packages using pip:
pip install trax
# Basic installation of Trax
- class wrapyfi.plugins.trax_array.TraxArray(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode Trax Array data using pickle and base64.
- Parameters:
obj – jaxlib.xla_extension.ArrayImpl: The Trax Array data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, pickled data string, and any buffer data
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a pickled and base64 encoded string back into Trax Array data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the pickled data string and any buffer data
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, pa.StructArray]: A tuple containing: - bool: Always True, indicating that the decoding was successful - jaxlib.xla_extension.ArrayImpl: The decoded Trax Array data
wrapyfi.plugins.xarray_data module
Encoder and Decoder for XArray DataArray/Dataset Data via Wrapyfi.
This script provides mechanisms to encode and decode XArray Data using Wrapyfi. It utilizes base64 encoding and JSON serialization.
The script contains a class, XArrayData, registered as a plugin to manage the conversion of XArray Data (DataArray and Dataset) (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
pandas: A data structures library for data analysis, time series, and statistics (refer to https://pandas.pydata.org/pandas-docs/stable/getting_started/install.html for installation instructions)
- XArray: N-D labeled arrays and datasets in Python (refer to http://xarray.pydata.org/en/stable/getting-started-guide/installing.html for installation instructions)
Note: If XArray is not available, HAVE_XARRAY will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install pandas xarray
# Basic installation of XArray
- class wrapyfi.plugins.xarray_data.XArrayData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode XArray Data using JSON and base64.
- Parameters:
obj – Union[xr.DataArray, xr.Dataset]: The XArray Data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, data type, and object name
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a JSON and base64 encoded string back into XArray Data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string, data type, and object name
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Union[xr.DataArray, xr.Dataset]]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Union[xr.DataArray, xr.Dataset]: The decoded XArray Data
wrapyfi.plugins.zarr_array module
Encoder and Decoder for Zarr Array/Group Data via Wrapyfi.
This script provides mechanisms to encode and decode Zarr Data using Wrapyfi. It utilizes base64 encoding and zip compression.
The script contains a class, ZarrData, registered as a plugin to manage the conversion of Zarr Data (Array and Group) (if available) between its original and encoded forms.
- Requirements:
Wrapyfi: Middleware communication wrapper (refer to the Wrapyfi documentation for installation instructions)
- Zarr: A format for the storage of chunked, compressed, N-dimensional arrays (refer to https://zarr.readthedocs.io/en/stable/ for installation instructions)
Note: If Zarr is not available, HAVE_ZARR will be set to False and the plugin will be registered with no types.
- You can install the necessary packages using pip:
pip install zarr
# Basic installation of Zarr
- class wrapyfi.plugins.zarr_array.ZarrData(**kwargs)[source]
Bases:
Plugin
- encode(obj, *args, **kwargs)[source]
Encode Zarr Data using zip compression and base64.
- Parameters:
obj – Union[zarr.Array, zarr.Group]: The Zarr Data to encode
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, dict]: A tuple containing: - bool: Always True, indicating that the encoding was successful - dict: A dictionary containing:
’__wrapyfi__’: A tuple containing the class name, encoded data string, data type, and object name.
- decode(obj_type, obj_full, *args, **kwargs)[source]
Decode a zip compressed and base64 encoded string back into Zarr Data.
- Parameters:
obj_type – type: The expected type of the decoded object (not used)
obj_full – tuple: A tuple containing the encoded data string, data type, and object name
args – tuple: Additional arguments (not used)
kwargs – dict: Additional keyword arguments (not used)
- Returns:
Tuple[bool, Union[zarr.Array, zarr.Group]]: A tuple containing: - bool: Always True, indicating that the decoding was successful - Union[zarr.Array, zarr.Group]: The decoded Zarr Data