sway(probes): eager-import shipped probes so the registry is populated
- SHA
6537793a42e674574037bc11428084f9126fd60d- Parents
-
70bc167 - Tree
222befd
6537793
6537793a42e674574037bc11428084f9126fd60d70bc167
222befd| Status | File | + | - |
|---|---|---|---|
| M |
src/dlm_sway/probes/__init__.py
|
20 | 1 |
| M |
tests/conftest.py
|
5 | 0 |
src/dlm_sway/probes/__init__.pymodified@@ -1,1 +1,20 @@ | ||
| 1 | -"""Probe primitives. Each module in this package implements one primitive.""" | |
| 1 | +"""Probe primitives. Each module in this package implements one primitive. | |
| 2 | + | |
| 3 | +Importing this package eagerly imports every probe module so their | |
| 4 | +``__init_subclass__`` hooks populate the registry. If you're hitting | |
| 5 | +"unknown probe kind" from :func:`dlm_sway.probes.base.build_probe`, the | |
| 6 | +fix is to ``import dlm_sway.probes`` before building the probe — which | |
| 7 | +this ``__init__`` does for you. | |
| 8 | +""" | |
| 9 | + | |
| 10 | +from __future__ import annotations | |
| 11 | + | |
| 12 | +# Register every shipped probe with the central registry by importing | |
| 13 | +# its module. Order is not load-bearing for registration but matches the | |
| 14 | +# categorical grouping in :mod:`dlm_sway.core.result`. | |
| 15 | +from dlm_sway.probes import ( # noqa: F401 — imports register the probes | |
| 16 | + adapter_revert, | |
| 17 | + delta_kl, | |
| 18 | + null_adapter, | |
| 19 | + prompt_collapse, | |
| 20 | +) | |
tests/conftest.pymodified@@ -9,6 +9,11 @@ from __future__ import annotations | ||
| 9 | 9 | |
| 10 | 10 | import pytest |
| 11 | 11 | |
| 12 | +# Import the probes package once so every shipped probe registers itself | |
| 13 | +# with the central registry. Tests that exercise build_probe("delta_kl", | |
| 14 | +# …) rely on this. | |
| 15 | +import dlm_sway.probes # noqa: F401 | |
| 16 | + | |
| 12 | 17 | |
| 13 | 18 | @pytest.fixture(autouse=True) |
| 14 | 19 | def _offline_and_no_telemetry(monkeypatch: pytest.MonkeyPatch) -> None: |