qfa.utils#
Utility functions for the feedback analysis backend.
Functions
|
Set up the logging system. |
|
Measure the wall-clock duration of a block, without logging anything. |
Classes
- class qfa.utils.Stopwatch(elapsed_seconds: float = 0.0)[source]#
Bases:
objectHolds the measured wall-clock duration of a
timed()block.
- qfa.utils.timed() Iterator[Stopwatch][source]#
Measure the wall-clock duration of a block, without logging anything.
Yields a
Stopwatchwhoseelapsed_secondsis populated when the block exits — including when it raises, so a phase that fails still reports how long it ran. Measurement is deliberately decoupled from logging: the caller owns the log message, so it controls the level and guarantees only content-free values (counts, latencies) reach the log, per the hard prohibitions indocs/operations/observability.md.Uses
time.perf_counter()(monotonic) so it is unaffected by wall-clock adjustments such as NTP steps.Examples
Time a phase, then log a content-free summary yourself:
with timed() as sw: vectors = embedder.embed(texts) logger.info("embedded %d record(s) in %.2fs", len(texts), sw.elapsed_seconds)
- qfa.utils.setup_logging(log_settings: LogSettings | None = None) None[source]#
Set up the logging system.
- Parameters:
log_settings (LogSettings | None) – Optional logging configuration. When
Nonea defaultLogSettingsinstance is created.