Source code for diffBloch.app.loggers.wandb
"""Weights & Biases logger backend -- the only module that touches the ``wandb`` SDK.
``wandb`` is imported lazily inside :meth:`WandbLogger.report`, so it is an optional dependency
(``uv sync --extra wandb``): importing ``diffBloch.app.loggers`` never requires it, and the pure
core never touches it. The app owns the run lifecycle (``wandb.init`` / ``wandb.finish``); this
logger only forwards each event's measurements to the active run as ``{channel}/{metric}`` series.
"""
from __future__ import annotations
from dataclasses import dataclass
from diffBloch.app.loggers import namespaced_measurements
from diffBloch.observability import Event
[docs]
@dataclass
class WandbLogger:
"""Log each event's measurements to Weights & Biases as ``{channel}/{metric}`` series."""
[docs]
def report(self, event: Event) -> None:
import wandb # lazy: optional dependency, never imported by the pure core
wandb.log(namespaced_measurements(event), step=event.step)