Skip to content

Fix error messages for sub-device access of setters#828

Open
cappel89 wants to merge 4 commits into
mainfrom
fix-sub-device-config-access-raises-proper-error
Open

Fix error messages for sub-device access of setters#828
cappel89 wants to merge 4 commits into
mainfrom
fix-sub-device-config-access-raises-proper-error

Conversation

@cappel89
Copy link
Copy Markdown
Member

Changing config attributes of sub-devices is not supported for RPC devices, i.e. read_only, readoutPriority, limits etc. Previously, the error message for this was rather obscure:

image

This PR fixes this. Error messages for access of relevant attributes of sub-devices has been improved.

image

@cappel89 cappel89 requested a review from a team April 22, 2026 12:07
@cappel89 cappel89 self-assigned this Apr 22, 2026
Copilot AI review requested due to automatic review settings April 22, 2026 12:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a dedicated exception type to provide clearer, user-facing errors when attempting to modify configuration attributes on sub-devices (which is not supported), and adds tests covering these behaviors.

Changes:

  • Added NotImplementedOnSubdeviceError (an AlarmBase) with a clearer message for unsupported sub-device config operations.
  • Added sub-device guards to multiple config setters / helpers (e.g., enabled, read_only, readout_priority, limits, tags, user parameters).
  • Added tests that exercise sub-device reads (allowed) vs. writes (now raising the new exception).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
bec_lib/bec_lib/device.py Adds NotImplementedOnSubdeviceError and raises it from various config setters when called on sub-devices.
bec_lib/tests/test_devices.py Adds fixtures/tests to verify sub-device config setters raise NotImplementedOnSubdeviceError.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bec_lib/tests/test_devices.py Outdated
Comment thread bec_lib/tests/test_devices.py
Comment thread bec_lib/tests/test_devices.py
Comment thread bec_lib/bec_lib/device.py Outdated
Comment thread bec_lib/bec_lib/device.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 73.68421% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bec_lib/bec_lib/device.py 73.68% 6 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@cappel89 cappel89 force-pushed the fix-sub-device-config-access-raises-proper-error branch from 6d73eb2 to bc628b1 Compare April 22, 2026 12:59
Comment thread bec_lib/bec_lib/device.py
d-perl
d-perl previously approved these changes Apr 22, 2026
Copy link
Copy Markdown
Contributor

@d-perl d-perl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, one comment in code which could save a couple of lines if you wanted, optional

Comment thread bec_lib/bec_lib/device.py Outdated
Comment thread bec_lib/bec_lib/device.py
@typechecked
def set_user_parameter(self, val: dict):
"""set the user parameter for this device"""
if self.name != self.root.name:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

self.root is not self

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cappel89 friendly reminder ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants