Processor-related fixes - #89
Open
C-Achard wants to merge 27 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses two processor-related UX/plug-in discovery issues in DeepLabCut-live-GUI: (1) ensuring DLC/processor controls correctly re-enable after preview stop, and (2) improving processor class discovery so indirect dlclive.Processor subclasses can be surfaced in the GUI.
Changes:
- Adds a shared
discover_processor_classes()helper to finddlclive.Processorsubclasses (including indirect subclasses) and reuses it for both package and file-based processor loading. - Hooks
allow_processor_ctrl_checkboxchanges into UI update routines, and refreshes DLC control enabled-state on multi-camera preview start/stop. - Simplifies DLC control enabling logic so processor-related widgets re-enable based on inference state.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dlclivegui/processors/processor_utils.py | Refactors processor discovery into reusable helpers and uses them for package/file scanning. |
| dlclivegui/gui/main_window.py | Updates signal wiring and control enable/disable logic to restore processor/DLC UI states after preview transitions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
July 1, 2026 14:21
b7c1b12 to
eaee775
Compare
C-Achard
force-pushed
the
cy/processor-fixes
branch
2 times, most recently
from
July 2, 2026 14:36
52f9b92 to
a800c08
Compare
C-Achard
changed the base branch from
cy/improve-encoding-speed
to
cy/hardware-timestamps
July 2, 2026 14:37
C-Achard
changed the base branch from
cy/hardware-timestamps
to
cy/improve-encoding-speed
July 2, 2026 14:37
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
July 14, 2026 09:03
a800c08 to
f4859fb
Compare
C-Achard
changed the base branch from
cy/improve-encoding-speed
to
cy/hardware-timestamps
July 14, 2026 09:04
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
July 14, 2026 09:44
f4859fb to
7ca8905
Compare
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
July 16, 2026 09:47
7ca8905 to
ee5b82c
Compare
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
July 16, 2026 11:15
ee5b82c to
571175e
Compare
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
August 10, 2026 12:11
571175e to
59b2d26
Compare
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
August 12, 2026 16:21
0e31615 to
82cd548
Compare
Disable all DLC and processor configuration widgets consistently while inference is active, including the processor-control checkbox. Refactor processor discovery into shared helpers that detect direct and indirect `dlclive.Processor` subclasses, standardize metadata extraction, and reuse the same fallback logic for package scans and file-based loading.
Expand processor class discovery to include re-exported classes by disabling module-only filtering in package/file scans. Also broaden subclass-check error handling to catch unexpected exceptions and log full context when discovery encounters problematic objects.
Create `dlclivegui/processors/__init__.py` to re-export `register_processor`, `BaseProcessorSocket`, and `PROCESSOR_REGISTRY` from `dlc_processor_socket`, making these APIs available via package-level imports.
Refactors `dlc_processor_socket.py` by removing the in-file example processors and `OneEuroFilter`, and adds them to a new `dlclivegui/processors/examples.py` module. This separates demonstration/experiment-specific logic from the core socket processor implementation, improving maintainability while preserving existing example processor behavior.
Refines `PLUGIN_SYSTEM.md` to reflect the current processor structure: it now points to `examples.py` for sample implementations and keeps `dlc_processor_socket.py` focused on the socket base class. The registration example was also updated to import `register_processor` and `PROCESSOR_REGISTRY` from `dlclivegui.processors` instead of redefining them inline.
Update processor package discovery to ignore `dlc_processor_socket` during namespace scanning, since it only provides the base class/registry and should not be listed as an available processor source. The package fallback scan now uses default class discovery behavior, and related outdated comments/docstring lines were cleaned up.
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.
Updates `scan_processor_package` to use a more precise return type annotation (`dict[str, dict]`
Update processor imports to use `from dlclive.processor import Processor` in runtime code to avoid torch import side effects
Moves processor registration and discovery helpers out of `dlc_processor_socket.py` into a new `registry.py` module so registry access no longer depends on importing socket logic. `dlc_processor_socket.py` now imports the shared registry helpers and adds a safe fallback when `dlclive` is unavailable, reducing import-time failures in environments without that dependency. Package exports were updated to expose registry APIs from the new module.
Update the base processor test helper to better mirror the real dlclive package layout by mocking both `dlclive` and `dlclive.processor`, and add a no-op `process` method on the dummy `Processor`. This prevents import/behavior mismatches in tests that rely on the processor interface.
Update `Engine` to inherit from `str, Enum` so enum members behave like strings where needed. Also harden `from_model_type` by coercing non-string inputs (including enum-like values with `.value`) before lowercasing, and raise a clear `ValueError` when conversion is not possible.
Remember the processor folder across sessions and use it when initializing the main window. The folder is now saved when browsing, during refresh (after resolving a valid directory), and on close. Processor refresh messaging was updated to show whether processors came from the selected folder or the built-in package. Settings store gained processor-folder get/set helpers that validate and normalize paths, with safe fallback to defaults when paths are missing or invalid.
Enhance error reporting and handling for video recording. recording_manager now logs exception type, message, and frame shape/dtype when a write fails. VideoRecorder adds detailed messages for frame-size mismatches, queue retrieval errors, and encoding failures (including frame description, expected size, frames_written/frames_enqueued/dropped, and queue_size) and stops the recorder to avoid FFmpeg pipe errors. Introduced _describe_frame to summarize frames and _set_encode_error to centralize creation of a RuntimeError (preserving original exception as __cause__) and set _encode_error under the stats lock. Minor test file newline fix.
Mark `BaseProcessorSocket` as non-discoverable and update processor subclass filtering to respect a class-level `PROCESSOR_DISCOVERABLE = False` flag only when set on the class itself. This keeps abstract/base classes out of selectable processor lists while allowing concrete subclasses to remain discoverable by default. Also improves the subclass-check docstring and exception logging message formatting.
Refactors processor scanning to consistently discover classes via `discover_processor_classes` for both package and file scans, removing the `get_available_processors` special-case path. Adds `_add_processor_results` to centralize normalization of scan entries (`file`, `class_name`, `file_path`) and avoid duplicated mutation logic. Also tightens function signatures with explicit type hints for scan/load/instantiate helpers.
Marks the decorator-based processor registry as legacy and adds DeprecationWarning notices to registration, listing, and instantiation helpers. It also adds type hints and clearer docstrings, improves duplicate-key logging, and updates unknown-processor errors to better reflect legacy usage.
Refactors test helper modules to define real `Processor` subclasses instead of exposing `get_available_processors`, aligning tests with subclass-based discovery behavior. Renames the file-loading test accordingly, simplifies assertions to match the new discovery path, and adds a regression test ensuring legacy `@register_processor` usage remains import-compatible while emitting a `DeprecationWarning`.
Remove the runtime fallback that replaced `dlclive.processor.Processor` with `object` and import `Processor` directly in `dlc_processor_socket`. Update custom processor tests to stop mocking `dlclive`; they now use `pytest.importorskip` and import real modules only when DLCLive is installed.
Expand built-in discovery coverage by importing and using `discover_processor_classes` and `_is_processor_subclass` in processor utility tests. The new tests ensure the `dlclivegui.processors.examples` module exposes discoverable `Processor` subclasses and specifically verify that `ExampleProcessorSocketCalculateMousePose` remains selectable under the discovery rules.
Revise PLUGIN_SYSTEM.md to reflect class-based processor discovery (including PROCESSOR_DISCOVERABLE behavior) instead of registry-driven discovery, and document legacy registration compatibility. Clarify GUI control-gating semantics, socket processor expectations, and modern instructions for creating and configuring custom processors.
Renames and repurposes processor control UI to a custom-processor toggle tied to processor selection, including a combined status/toggle row that only appears when a processor is chosen. Processor instantiation and status updates are now gated by the new `_custom_processor_enabled` logic, and disabled selections are explicitly reported without loading a plugin. Updated the recording paths UI test to use the new checkbox.
Refactor `test_processor_overrides_session_name_and_persists` for clarity and reliability by setting up the processor combo selection explicitly, keeping DLC state initialization together, and formatting monkeypatch/setup logic more readably. The assertions still verify that processor-generated session names update the UI and are passed into recording start kwargs.
Adds a GUI regression test to ensure processor-related controls are disabled while inference is active and properly re-enabled when it stops. Also updates plugin system docs by fixing a description typo and aligning the toggle name to "Use custom processor".
C-Achard
force-pushed
the
cy/processor-fixes
branch
from
August 12, 2026 16:26
82cd548 to
6ab33f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #87 and closes #88