juturna.payloads package

Module contents

class juturna.payloads.AudioPayload(audio: numpy.ndarray = <factory>, sampling_rate: int = -1, audio_format: str = '', channels: int = -1, start: float = -1.0, end: float = -1.0)

Bases: BasePayload

audio: ndarray
audio_format: str = ''
channels: int = -1
end: float = -1.0
sampling_rate: int = -1
static serialize(obj) → dict

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

property size_bytes: int
start: float = -1.0
class juturna.payloads.BasePayload

Bases: object

clone() → Self
static serialize(obj) → dict

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

class juturna.payloads.Batch(messages: tuple = <factory>)

Bases: BasePayload

messages: tuple
static serialize(obj) → list

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

property size_bytes: int
class juturna.payloads.BytesPayload(cnt: bytes = <factory>)

Bases: BasePayload

cnt: bytes
static serialize(obj) → dict

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

property size_bytes: int
class juturna.payloads.Draft(payload_type: T, copy_from: T | None = None)

Bases: Generic

Payloads can be built using drafts. A draft stores the payload values, and once it is compiled an actual payload will be generated.

clear()

Clear all stored keys and values

compile() → T

Compile the payload, using all the stored key-value items.

Returns:

A new payload.

Return type:

BasePayload

Raises:

TypeError – If the draft was not open, so the payload type was not set, the method raises a TypeError.

class juturna.payloads.ImagePayload(image: numpy.ndarray = <factory>, width: int = -1, height: int = -1, depth: int = -1, pixel_format: str = '', timestamp: float = -1.0)

Bases: BasePayload

depth: int = -1
height: int = -1
image: ndarray
pixel_format: str = ''
static serialize(obj) → dict

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

property size_bytes: int
timestamp: float = -1.0
width: int = -1
class juturna.payloads.ObjectPayload(**kwargs)

Bases: dict, BasePayload

Immutable dictionary payload, with items also readable as attributes.

Every dict method that changes the content raises TypeError. Only the top level is frozen: mutable values (lists, dicts, arrays) can still be changed in place, and should be treated as read-only.

clear() → None.  Remove all items from D.
static from_dict(origin: dict)
pop(k[, d]) → v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(*args)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

property size_bytes: int

Approximate memory held by the payload and its values, in bytes.

The size is computed on first access (only telemetry reads it), then cached. The walk takes at most JUTURNA_PAYLOAD_SIZE_MAX_VISITS steps, so the value is a lower bound for payloads with many nested objects, and in-place changes to nested values after the first access are not reflected.

update([E, ]**F) → None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

class juturna.payloads.VideoPayload(video: tuple[juturna.payloads._payloads.ImagePayload, ...] = <factory>, frames_per_second: float = -1.0, codec: str = '', start: float = -1.0, end: float = -1.0)

Bases: BasePayload

codec: str = ''
end: float = -1.0
frames_per_second: float = -1.0
static serialize(obj) → dict

Convert a dataclass payload into JSON-compatible values, field by field: arrays become lists, bytes become base64 text, and nested payloads use their own serialize.

Raises:

TypeError – If the payload class is not itself a dataclass, so it has no fields to serialise.

property size_bytes: int
start: float = -1.0
video: tuple[ImagePayload, ...]