Skip to content

Commit 04431ce

Browse files
committed
Warn on duplicate processor registration
Change `register_processor` to log a warning instead of raising on duplicate `PROCESSOR_ID` keys, allowing later registrations to override earlier ones without import-time failures. Update subclass save tests to load processor classes from `dlclivegui.processors.examples` via a dedicated fixture, so the parametrized tests validate the concrete example processors against the correct module data path.
1 parent abf1072 commit 04431ce

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

dlclivegui/processors/dlc_processor_socket.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
def register_processor(cls):
3131
registry_key = getattr(cls, "PROCESSOR_ID", cls.__name__)
3232
if registry_key in PROCESSOR_REGISTRY:
33-
raise ValueError(
33+
msg = (
3434
f"Duplicate processor registration key '{registry_key}': "
3535
f"{PROCESSOR_REGISTRY[registry_key].__name__} vs {cls.__name__}"
3636
)
37+
logger.warning(msg)
3738
PROCESSOR_REGISTRY[registry_key] = cls
3839
return cls
3940

tests/custom_processors/test_base_processor.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ def socket_mod(monkeypatch):
3737
return importlib.import_module(mod_name)
3838

3939

40+
@pytest.fixture
41+
def example_processor_mod(monkeypatch):
42+
"""
43+
Import the example processor module with dlclive mocked.
44+
Adjust module name if your file lives elsewhere.
45+
"""
46+
_mock_dlclive(monkeypatch)
47+
mod_name = "dlclivegui.processors.examples"
48+
if mod_name in sys.modules:
49+
del sys.modules[mod_name]
50+
return importlib.import_module(mod_name)
51+
52+
4053
def _module_data_dir(socket_mod) -> Path:
4154
"""Compute the data/ directory where save() writes artifacts."""
4255
return Path(socket_mod.__file__).parent.parent.parent / "data"
@@ -233,12 +246,14 @@ def test_save_ignores_pre_recording_original_pose_frames(socket_mod):
233246
("ExampleProcessorSocketFilterKeypoints", 10),
234247
],
235248
)
236-
def test_subclass_save_ignores_pre_recording_original_pose_frames(socket_mod, class_name, n_keypoints):
249+
def test_subclass_save_ignores_pre_recording_original_pose_frames(
250+
socket_mod, example_processor_mod, class_name, n_keypoints
251+
):
237252
"""
238253
Concrete processors must keep original_pose aligned with recorded metadata
239254
even when process() is called before recording starts.
240255
"""
241-
processor_class = getattr(socket_mod, class_name)
256+
processor_class = getattr(example_processor_mod, class_name)
242257
proc = processor_class(bind=("127.0.0.1", 0), save_original=True)
243258

244259
try:

0 commit comments

Comments
 (0)