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

Use ophyd_async DerivedSignals #1140

Open
DominicOram opened this issue Mar 25, 2025 · 6 comments · Fixed by bluesky/ophyd-async#843 · May be fixed by #1148
Open

Use ophyd_async DerivedSignals #1140

DominicOram opened this issue Mar 25, 2025 · 6 comments · Fixed by bluesky/ophyd-async#843 · May be fixed by #1148
Assignees
Labels
good first issue Good for newcomers

Comments

@DominicOram
Copy link
Contributor

Following bluesky/ophyd-async#661 there is now a DerivedSignal in ophyd_async that should be able to replace the hardware_backed_signal we have made in dodal.

Acceptance Criteria

  • hardware_backed_signals are replaced by DerivedSignals from ophyd_async
  • Tests still pass
  • Any issue with the interface are fed back to ophyd-async
@DominicOram DominicOram added the good first issue Good for newcomers label Mar 25, 2025
@Relm-Arrowny
Copy link
Contributor

Can I pick this up, I am going to have to do it for i10 id and current amplifier later.

@DominicOram
Copy link
Contributor Author

Sure, sounds good!

@DominicOram
Copy link
Contributor Author

Note that you will have linting/test issues until #1143 is sorted

@Relm-Arrowny
Copy link
Contributor

Relm-Arrowny commented Mar 27, 2025

I have a quick try at making the change and I run into an issue, it appears the signal type is extracted from the type hint of the transformation function but at the moment it only support python build in type, if I try to use a custom type I get the following error:

  File "/usr/local/lib/python3.11/typing.py", line 2414, in get_type_hints
    hints[name] = _eval_type(value, globalns, localns)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/typing.py", line 395, in _eval_type
    return t._evaluate(globalns, localns, recursive_guard)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/typing.py", line 905, in _evaluate
    eval(self.__forward_code__, globalns, localns),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
NameError: name 'ApertureValue' is not defined

which is caused by get_type_hints as ApertureValue is not define in _derived signal scope, I can make the device work by defining ApertureValue within _derived_signal.py.

To Reproduce
Run test_aperture_scatterguard.py in this branch.

Expected behavior
I think we expect to be able to use custom type in derived signals.

@DominicOram
Copy link
Contributor Author

I think this can currently be done with the more complete API https://blueskyproject.io/ophyd-async/main/how-to/derive-one-signal-from-others.html#multi-derived-signal. I think it would be good to have this in the simple API if we can though, a common usecase we have is converting an enum of positions to/from motor values. Thoughts @coretl?

@coretl
Copy link
Collaborator

coretl commented Mar 28, 2025

bluesky/ophyd-async#843 should fix it, please could you test?

@Relm-Arrowny Relm-Arrowny reopened this Mar 28, 2025
@Relm-Arrowny Relm-Arrowny linked a pull request Mar 28, 2025 that will close this issue
4 tasks
@Relm-Arrowny Relm-Arrowny linked a pull request Mar 28, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
3 participants