Restructure IMU devices from Enum class to dict, populated during import using entry points - #83
Conversation
|
@claude-review |
|
Claude finished @NGierden's task in 2m 8s —— View job Code Review
SummaryThe approach is solid — replacing the 🐛 Bug: Key typo breaks
|
|
@claude-review, can you summarize me what has been added or changed in this PR? |
|
Claude finished @NGierden's task in 54s —— View job PR Summary
This PR replaces the static New:
|
| Old (enum methods) | New (module-level functions) |
|---|---|
IMUDevices.get_mock() |
get_mock() → tuple[str, IMUConfig] |
IMUDevices._from_address(addr) |
_from_address(addr) |
IMUDevices.get_config(addresses) |
get_config(addresses) |
The logic inside these functions is unchanged — they do the same address-matching and partial-config merging for split IMUs (LSM6DSOX+LIS3MDL) as before.
Changed: definitions.py (+2 lines)
- Added
MOCK_NAME = "MOCK"constant (used as the dict key for the mock sensor). - Added
IMUDescriptordataclass (name: str,index: int) to replace enum-based device identification in the detected-device dict.
Changed: pyproject.toml
- Version bumped:
0.1.0→0.1.1. - Two new entry point groups added:
[project.entry-points."imu_module.devices"] # downstream packages declare new IMU configs here [project.entry-points."imu_module.device_overrides"] # downstream packages override existing IMU configs here
Changed: Tests
All tests updated to use IMU_DEVICES[name] and the new helper functions instead of IMUDevices.<MEMBER>. A new registry_test.py is added, covering:
- Built-in devices load correctly as
IMUConfiginstances. - Known devices (e.g.
MOCK) are present in the registry. - The override mechanism replaces a built-in config when a matching entry point is present (tested with
unittest.mock).
Why this matters
Previously, adding a new IMU or tweaking a sensor config required modifying devices.py in this repo directly. With this change, any downstream package (e.g. exosuit-python) can register a new sensor or override an existing one just by adding entries to its own pyproject.toml — no fork needed.
Note: There are two bugs and several minor issues flagged in the earlier review comment above that should be addressed before merging.
NGierden
left a comment
There was a problem hiding this comment.
Actually, I don't think I have anything to add:) Please address claudes' comments and then you're ready to merge.
add on-board fusion support
Summary
Describe the main changes in this PR:
[project.entry-points."imu_module.devices"]and adds them to a dict calledIMU_DEVICES.IMUDevicesno longer exists. The methods that match the addresses to devices are now standalone.pyproject.toml.builtin_devices.pyfile to avoid circular import.Code Quality Checklist
Before requesting review, ensure:
make treeto update the README.mdAdditional Notes