mstar.streaming.stream_buffer#
Functions
|
A chunk's items as its consumer takes them: one item as itself, several stacked. |
Classes
|
Per-request, per-edge buffer on the CONSUMER worker. |
|
A chunk of data popped from a StreamBuffer. |
|
A chunk's place in its stream, without its data. |
|
A popped chunk as a synthetic input edge into its consumer node: the uuid of each of its items, and its place in the stream. |
- class mstar.streaming.stream_buffer.StreamBuffer(request_id, edge_name, from_partition, policy, join_dim=None, joiner=None, walk_tagged=False, _waiting_graph_edges=<factory>, ingested_chunk=None, _buffer=<factory>, _walk_runs=<factory>, _tensor_ids_in_order=<factory>, _id_to_tensor=<factory>, _consumed=0, _chunks_popped=0, _delivered_end=0, producer_done=False, _final_chunk_emitted=False, maybe_ready=True)[source]#
Bases:
objectPer-request, per-edge buffer on the CONSUMER worker.
Items arrive one-by-one via normal routing: tensors, or handles to them (the worker puts each item’s uuid and collates the tensors when the consuming batch is built). The buffer accumulates them and applies a ChunkPolicy to decide when the consuming node has enough data to proceed.
For sliding-window policies the buffer keeps old items so that pop_chunk can return the full window while only advancing by stride.
- Parameters:
request_id (int)
edge_name (str)
from_partition (str)
policy (ChunkPolicy)
join_dim (int | None)
walk_tagged (bool)
_waiting_graph_edges (deque[StreamingEdge])
ingested_chunk (StreamChunkInfo | None)
_buffer (list)
_tensor_ids_in_order (deque)
_id_to_tensor (dict)
_consumed (int)
_chunks_popped (int)
_delivered_end (int)
producer_done (bool)
_final_chunk_emitted (bool)
maybe_ready (bool)
- ingested_chunk: StreamChunkInfo | None = None#
- peek_walk()[source]#
The walk the next chunk runs under, without popping it. None when untagged or nothing is buffered.
- Return type:
str | None
- policy: ChunkPolicy#
- pop_chunk()[source]#
Pop the next chunk. Only call when has_chunk_ready() is True.
For sliding-window: returns window_size items, advances by stride items, discards items that have fallen out of the window. start_offset is the global position of the first item in the chunk.
- Return type:
- pop_waiting_edge()[source]#
- Return type:
StreamingEdge | None
- pre_read_register_joined(tensor_ids, walk=None)[source]#
Register
tensor_idsas the pieces of ONE item.A chunked producer emits a piece per chunk; without this each would be an item of its own and a policy counting items would hand the consumer only the first. Each piece still counts towards the registered total, which is in the producer’s units (see below).
- prime_context(context_items)[source]#
The first
context_itemsitems the producer sends are context only (e.g. a voice clone’s reference frames): the first chunk carries them ahead of its new items, reported ascontext_items.- Parameters:
context_items (int)
- Return type:
None
- put(tensor_id, item)[source]#
Called when an item arrives via normal routing.
- Parameters:
tensor_id (str)
- Return type:
None
- signal_done(num_items=0)[source]#
Producer signals no more items will arrive after the
num_itemsit sent in total.- Parameters:
num_items (int)
- Return type:
None
- store_uningested_edge(streaming_edge)[source]#
- Parameters:
streaming_edge (StreamingEdge)
- class mstar.streaming.stream_buffer.StreamChunk(data, chunk_index, start_offset=0, is_final=False, context_items=0, num_items=0, released=<factory>)[source]#
Bases:
objectA chunk of data popped from a StreamBuffer.
- Parameters:
- property info: StreamChunkInfo#
- class mstar.streaming.stream_buffer.StreamChunkInfo(start_offset, context_items, num_items, is_final)[source]#
Bases:
NamedTupleA chunk’s place in its stream, without its data.
- class mstar.streaming.stream_buffer.StreamingEdge(name, next_node, uuids, chunk)[source]#
Bases:
NamedTupleA popped chunk as a synthetic input edge into its consumer node: the uuid of each of its items, and its place in the stream.
- Parameters:
name (str)
next_node (str)
chunk (StreamChunkInfo)
- chunk: StreamChunkInfo#
Alias for field number 3