Aggregate result of running a flow over many inputs. ``results[i]`` is the output for ``inputs[i]`` or ``None`` if that input failed. ``errors`` carries ``(index, exception)`` for every failure, sorted by index. ``successes`` and ``failures`` are convenience views derived from these
| 20 | |
| 21 | @dataclass(slots=True) |
| 22 | class BatchResult(Generic[OutputT]): |
| 23 | """Aggregate result of running a flow over many inputs. |
| 24 | |
| 25 | ``results[i]`` is the output for ``inputs[i]`` or ``None`` if that |
| 26 | input failed. ``errors`` carries ``(index, exception)`` for every |
| 27 | failure, sorted by index. ``successes`` and ``failures`` are |
| 28 | convenience views derived from these primary fields. |
| 29 | """ |
| 30 | |
| 31 | total: int |
| 32 | success_count: int |
| 33 | failure_count: int |
| 34 | results: list[OutputT | None] |
| 35 | errors: list[tuple[int, Exception]] |
| 36 | duration_seconds: float |
| 37 | tokens_total: dict[str, int] = field(default_factory=dict) |
| 38 | cost_estimate_usd: float = 0.0 |
| 39 | |
| 40 | @property |
| 41 | def successes(self) -> list[tuple[int, OutputT]]: |
| 42 | """``(index, result)`` for every input that succeeded.""" |
| 43 | return [(i, r) for i, r in enumerate(self.results) if r is not None] |
| 44 | |
| 45 | @property |
| 46 | def failures(self) -> list[tuple[int, Exception]]: |
| 47 | """Alias for ``errors`` to mirror ``successes`` for symmetry.""" |
| 48 | return list(self.errors) |
| 49 | |
| 50 | |
| 51 | async def batch_run( |
no outgoing calls