Coverage for orchestrant/pipeline/__init__.py: 54%

13 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-22 09:57 +0000

1"""Monitoring pipeline package: capture, tracking, metrics, and viewers.""" 

2 

3from __future__ import annotations 

4 

5import importlib 

6from typing import TYPE_CHECKING 

7 

8 

9# Lazy (PEP 562): a light submodule import must not pull in cv2, Flet or GStreamer. 

10_EXPORTS = { 

11 "CameraCapture": "orchestrant.pipeline.capture", 

12 "OpenCVCapture": "orchestrant.pipeline.capture", 

13 "GStreamerSubprocessCapture": "orchestrant.pipeline.capture.gstreamer", 

14 "find_gstreamer_launch": "orchestrant.pipeline.capture.gstreamer", 

15 "get_gstreamer_env": "orchestrant.pipeline.capture.gstreamer", 

16 "attach_log_buffer": "orchestrant.pipeline.logging", 

17 "configure_logging": "orchestrant.pipeline.logging", 

18 "create_log_buffer": "orchestrant.pipeline.logging", 

19 "log_buffer_lines": "orchestrant.pipeline.logging", 

20 "PerformanceTracker": "orchestrant.pipeline.metrics.performance", 

21 "PowerMonitor": "orchestrant.pipeline.monitoring.power", 

22 "get_cpu_freq_ratio": "orchestrant.pipeline.monitoring.power", 

23 "SystemMonitor": "orchestrant.pipeline.monitoring.system", 

24 "SimpleCentroidTracker": "orchestrant.pipeline.tracking.centroid", 

25 "CameraConfig": "orchestrant.pipeline.types", 

26 "CaptureBackend": "orchestrant.pipeline.types", 

27 "PerformanceMetrics": "orchestrant.pipeline.types", 

28 "SystemStats": "orchestrant.pipeline.types", 

29 "Track": "orchestrant.pipeline.types", 

30 "FletViewer": "orchestrant.pipeline.ui.flet_viewer", 

31 "AMD_AVAILABLE": "orchestrant.monitoring.gpu", 

32 "PYNVML_AVAILABLE": "orchestrant.monitoring.gpu", 

33} 

34 

35 

36def __getattr__(name: str) -> object: 

37 """Resolve a public name from its home module on first access.""" 

38 if name in _EXPORTS: 

39 module = importlib.import_module(_EXPORTS[name]) 

40 return getattr(module, name) 

41 msg = f"module {__name__!r} has no attribute {name!r}" 

42 raise AttributeError(msg) 

43 

44 

45def __dir__() -> list[str]: 

46 """Advertise lazy exports to introspection alongside real attributes.""" 

47 return sorted(set(globals()) | set(__all__)) 

48 

49 

50__all__ = [ 

51 "AMD_AVAILABLE", 

52 "PYNVML_AVAILABLE", 

53 "CameraCapture", 

54 "CameraConfig", 

55 "CaptureBackend", 

56 "FletViewer", 

57 "GStreamerSubprocessCapture", 

58 "OpenCVCapture", 

59 "PerformanceMetrics", 

60 "PerformanceTracker", 

61 "PowerMonitor", 

62 "SimpleCentroidTracker", 

63 "SystemMonitor", 

64 "SystemStats", 

65 "Track", 

66 "attach_log_buffer", 

67 "configure_logging", 

68 "create_log_buffer", 

69 "find_gstreamer_launch", 

70 "get_cpu_freq_ratio", 

71 "get_gstreamer_env", 

72 "log_buffer_lines", 

73]