qfa.utils#

Utility functions for the feedback analysis backend.

Functions

setup_logging([log_settings])

Set up the logging system.

timed()

Measure the wall-clock duration of a block, without logging anything.

Classes

Stopwatch([elapsed_seconds])

Holds the measured wall-clock duration of a timed() block.

class qfa.utils.Stopwatch(elapsed_seconds: float = 0.0)[source]#

Bases: object

Holds the measured wall-clock duration of a timed() block.

elapsed_seconds: float = 0.0#
qfa.utils.timed() Iterator[Stopwatch][source]#

Measure the wall-clock duration of a block, without logging anything.

Yields a Stopwatch whose elapsed_seconds is 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 in docs/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 None a default LogSettings instance is created.