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

1"""Granular progress callback protocol for streaming pipeline events.""" 

2 

3from collections.abc import Callable 

4from enum import StrEnum 

5from typing import Any 

6 

7from pydantic import BaseModel 

8 

9 

10class EventType(StrEnum): 

11 """Progress event types emitted during sync/ingest.""" 

12 

13 FILE_START = "file_start" 

14 FILE_DONE = "file_done" 

15 BATCH_PROGRESS = "batch_progress" 

16 DONE = "done" 

17 EMBED = "embed" 

18 EXTRACT = "extract" 

19 

20 

21DetailedProgressCallback = Callable[[EventType, dict[str, Any]], None] 

22 

23 

24def noop_callback(event_type: EventType, data: dict[str, Any]) -> None: 

25 """Default no-op callback — discards all events.""" 

26 

27 

28class FileStartEvent(BaseModel): 

29 """Emitted when a file begins ingestion.""" 

30 

31 file: str 

32 total_files: int 

33 current_file: int 

34 

35 

36class FileDoneEvent(BaseModel): 

37 """Emitted when a file finishes ingestion (success or error).""" 

38 

39 file: str 

40 status: str 

41 chunks: int 

42 

43 

44class BatchProgressEvent(BaseModel): 

45 """Emitted after each file completes during batch ingestion.""" 

46 

47 file: str 

48 status: str 

49 current: int 

50 total: int 

51 

52 

53class SyncDoneEvent(BaseModel): 

54 """Emitted when the sync operation completes.""" 

55 

56 added: int 

57 updated: int 

58 removed: int 

59 failed: int