Coverage for src / lilbee / progress.py: 100%
31 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-16 08:27 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-16 08:27 +0000
1"""Granular progress callback protocol for streaming pipeline events."""
3from collections.abc import Callable
4from enum import StrEnum
5from typing import Any
7from pydantic import BaseModel
10class EventType(StrEnum):
11 """Progress event types emitted during sync/ingest."""
13 FILE_START = "file_start"
14 FILE_DONE = "file_done"
15 BATCH_PROGRESS = "batch_progress"
16 DONE = "done"
17 EMBED = "embed"
18 EXTRACT = "extract"
21DetailedProgressCallback = Callable[[EventType, dict[str, Any]], None]
24def noop_callback(event_type: EventType, data: dict[str, Any]) -> None:
25 """Default no-op callback — discards all events."""
28class FileStartEvent(BaseModel):
29 """Emitted when a file begins ingestion."""
31 file: str
32 total_files: int
33 current_file: int
36class FileDoneEvent(BaseModel):
37 """Emitted when a file finishes ingestion (success or error)."""
39 file: str
40 status: str
41 chunks: int
44class BatchProgressEvent(BaseModel):
45 """Emitted after each file completes during batch ingestion."""
47 file: str
48 status: str
49 current: int
50 total: int
53class SyncDoneEvent(BaseModel):
54 """Emitted when the sync operation completes."""
56 added: int
57 updated: int
58 removed: int
59 failed: int