Handler
results.handler.ResultsBuffer(indices, results)
dataclass
¶
results.handler.ResultsHandler(saver=None, save_interval=1)
¶
Bases: Generic[OutputType]
Handler that accumulates Result[OutputType]
instances and supports
periodic flush/save and final aggregation.
PARAMETER | DESCRIPTION |
---|---|
saver
|
An instance of a Saver responsible for persisting results. If None, no saving is performed.
TYPE:
|
save_interval
|
The minimum number of results required before triggering a save.
TYPE:
|
buffer = ResultsBuffer(indices=[], results=[])
instance-attribute
¶
n_results = 0
instance-attribute
¶
save_interval = save_interval
instance-attribute
¶
saver = saver
instance-attribute
¶
add_result(result, *args, **kwargs)
¶
Adds a batch of results to the handler. This method is typically called when a parallel task (such as a Ray task) completes execution.
If a batch_index
is provided, the batch is buffer until all prior batches
have been processed to maintain the original submission order. If no
batch_index
is provided (i.e., when running sequentially), the batch
results are appended directly to the final results.
PARAMETER | DESCRIPTION |
---|---|
results
|
The list of results produced by a batch.
|
finalize()
¶
get()
¶
save()
¶
Persists a slice of the currently collected results if a saving interval has been met.
This method is typically called by a TaskManager after each batch is added. If a Saver is provided and the number of collected results meets or exceeds the specified save_interval, a slice of results is saved using the saver, and the saved results are removed from the in-memory collection.
Args: