herostools.actor.archiver.array

Classes

ArrayArchiver

HERODataArchiver that saves numpy arrays as .npy files.

Module Contents

class herostools.actor.archiver.array.ArrayArchiver(save_template: str, split_data_array: bool = False, *args, **kwargs)[source]

Bases: herostools.actor.archiver.base.HERODataArchiver

HERODataArchiver that saves numpy arrays as .npy files.

Parameters:
  • object_selector – Zenoh object selector for the devices to subscribe to.

  • event_name – Name of the event.

  • save_template – Jinja2 template used to generate the output file path from the payload metadata.

  • split_data_array – When True, each row of a 2-D array is saved as a separate file. Use {{ _split_index }} in save_template to embed the row index in the filename.

  • default_metadata – Default metadata available to the filename template.

  • max_retries – Number of times to retry a failed store before dropping the item.

Example

BOSS json configuration:

{
  "_id": "my-camera-capturer",
  "classname": "herostools.archiver.ArrayArchiver",
  "arguments": {
    "object_selector": "my-camera",
    "event_name": "acquisition_data",
    "default_metadata": {
      "file_path": "/mnt/mystorage/images"
    },
    "save_template": "{{ file_path }}/testimg-{{ '%04d' % ( frame / 2 ) |round(0, 'floor') }}-{{ frame % 2 }}.npy"
  }
}

Generates paths such as:

/mnt/mystorage/images/testimg-0000-0.npy
/mnt/mystorage/images/testimg-0000-1.npy
name_template
split_data_array = False
_store(source_name: str, payload: numpy.typing.NDArray[Any], metadata: dict) None[source]

Save the payload as a numpy .npy file.

Parameters:
  • source_name – Name of the event source (the HERO).

  • payload – Data to save as a numpy array.

  • metadata – Incoming metadata merged with default_metadata.