Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting on hardware backed signals #1078

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DominicOram
Copy link
Contributor

Fixes #1077

Instructions to reviewer on how to test:

  1. Confirm new tests pass

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}



class HardwareBackedSoftSignalBackend(SoftSignalBackend[SignalDatatypeT]):
def __init__(
self,
get_from_hardware_func: Callable[[], Coroutine[Any, Any, SignalDatatypeT]],
set_to_hardware_func: Callable[[], Coroutine[SignalDatatypeT, Any, Any]] = None,
Copy link
Contributor

@Relm-Arrowny Relm-Arrowny Feb 28, 2025

Choose a reason for hiding this comment

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

I think set_to_hardware_func should take a set value?

Suggested change
set_to_hardware_func: Callable[[], Coroutine[SignalDatatypeT, Any, Any]] = None,
set_to_hardware_func: Callable[[SignalDatatypeT], Coroutine[SignalDatatypeT, Any, Any]]
| None = None,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I missed it 'cos the linter is still broken due to #1072

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.68%. Comparing base (5893821) to head (cd09383).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/dodal/common/signal_utils.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1078      +/-   ##
==========================================
- Coverage   97.69%   97.68%   -0.02%     
==========================================
  Files         160      160              
  Lines        6635     6644       +9     
==========================================
+ Hits         6482     6490       +8     
- Misses        153      154       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Relm-Arrowny Relm-Arrowny left a comment

Choose a reason for hiding this comment

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

As I try to use it, I spotted a couple of things.

Comment on lines +42 to +48
def create_rw_hardware_backed_soft_signal(
datatype: type[SignalDatatypeT],
get_from_hardware_func: Callable[[], Coroutine[Any, Any, SignalDatatypeT]],
set_to_hardware_func: SetHardwareType,
units: str | None = None,
precision: int | None = None,
):
Copy link
Contributor

@Relm-Arrowny Relm-Arrowny Feb 28, 2025

Choose a reason for hiding this comment

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

never mind, I notice, it will always get overwrite.

Suggested change
def create_rw_hardware_backed_soft_signal(
datatype: type[SignalDatatypeT],
get_from_hardware_func: Callable[[], Coroutine[Any, Any, SignalDatatypeT]],
set_to_hardware_func: SetHardwareType,
units: str | None = None,
precision: int | None = None,
):
def create_rw_hardware_backed_soft_signal(
datatype: type[SignalDatatypeT],
get_from_hardware_func: Callable[[], Coroutine[Any, Any, SignalDatatypeT]],
set_to_hardware_func: Callable[[SignalDatatypeT], Coroutine[Any, Any, None]],
initial_value: SignalDatatypeT | None = None,
units: str | None = None,
precision: int | None = None,
) -> SignalRW:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yh, I think it's an edge case anyway and initial_value is probably never going to be None

precision=precision,
)
)


def create_hardware_backed_soft_signal(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Make it match soft_r /soft_rw ?

Suggested change
def create_hardware_backed_soft_signal(
def create_r_hardware_backed_soft_signal(

@DominicOram DominicOram requested a review from Relm-Arrowny March 6, 2025 14:44
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.

Allow passing a setter to create_hardware_backed_soft_signal
2 participants