fix(device_server): add conversion for enum strings from float values#1004
Open
wakonig wants to merge 1 commit into
Open
fix(device_server): add conversion for enum strings from float values#1004wakonig wants to merge 1 commit into
wakonig wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the device server to coerce float-like enum indices into integers when setting ophyd enum-backed signals, addressing cases where upstream layers (legacy scans / GUI) provide numeric values as floats.
Changes:
- Add
DeviceServer.convert_value_if_needed(...)and apply it in the device server’s_set_devicepath. - Apply the same conversion in the RPC “set/put” path before executing the RPC call.
- Add unit tests covering conversion behavior (including NumPy float scalars) and error handling for non-integral floats.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
bec_server/bec_server/device_server/device_server.py |
Adds and applies a helper to convert integral float enum indices to int before calling set. |
bec_server/bec_server/device_server/rpc_handler.py |
Converts the first RPC arg for set/put calls using the new helper before executing the RPC call. |
bec_server/tests/tests_device_server/test_device_server.py |
Adds tests validating enum float conversion (including NumPy floats) and rejection of non-integral floats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wakonig
force-pushed
the
fix/enum_str_conversion
branch
from
July 15, 2026 11:47
1ce8385 to
9b1cc60
Compare
wakonig
force-pushed
the
fix/enum_str_conversion
branch
from
July 15, 2026 11:49
9b1cc60 to
9629021
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Description
Converting floats to ints if the underlying signal is based on string enums.
Additional Comments
This currently only happens for legacy scans as they convert the inputs to a numpy array of floats. For v4-type scans the input types are kept. However, using the GUI will likely also emit floats as the inputs are given through a doublespincombobox. So it is probably a good idea to convert them to ints on the device server if possible.
Definition of Done