Skip to content

Convert transfocator to ophyd_async#941

Merged
shihab-dls merged 14 commits intomainfrom
748_convert_transfocator_to_ophyd_async
Dec 18, 2024
Merged

Convert transfocator to ophyd_async#941
shihab-dls merged 14 commits intomainfrom
748_convert_transfocator_to_ophyd_async

Conversation

@shihab-dls
Copy link
Contributor

Fixes #748

Instructions to reviewer on how to test:

  1. Check if signal components converted to analogous ophyd_async types.
  2. Check if setting device results in expected behaviour.

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}

@shihab-dls shihab-dls requested a review from a team as a code owner December 3, 2024 14:16
@codecov
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.42%. Comparing base (fa78284) to head (0cc4c6a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #941      +/-   ##
==========================================
+ Coverage   97.38%   97.42%   +0.03%     
==========================================
  Files         143      143              
  Lines        6087     6087              
==========================================
+ Hits         5928     5930       +2     
+ Misses        159      157       -2     

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

@shihab-dls shihab-dls force-pushed the 748_convert_transfocator_to_ophyd_async branch from 4a373d5 to 820f4d8 Compare December 3, 2024 14:20
@olliesilvester olliesilvester self-requested a review December 3, 2024 15:38
@olliesilvester
Copy link
Contributor

CI initially failed due to a flakey unit test unrelated to this PR, it passed after re-running. See #943

Copy link
Contributor

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great so far!

I've left a few comments, but the main one is something I incorrectly suggested to you, which was to not bother running set in the background by using asyncio.create_task. The original code ran set asynchronously, so we should try to keep that.

By the way, if you're curious, this was the recently added policy for reviews in dodal: https://diamondlightsource.github.io/dodal/main/explanations/reviews.html

Copy link
Contributor

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

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

Looks mostly good now, just a couple more things. When you're happy with this, we can create a short bluesky plan to test this device on the beamline

Copy link
Contributor

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

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

This seemed to work well during testing. A few minor features were requested by David on I04:

  • Add the signals for the read-back values for the number of lenses and the vertical beam size, BL04I-MO-FSWT-01:NUM_FILTERS and BL04I-MO-FSWT-01:VER
  • After the set is done, log the readbacks for the above

Copy link
Contributor

@olliesilvester olliesilvester left a comment

Choose a reason for hiding this comment

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

Thanks! Looks neater than the old device 🥳

@shihab-dls shihab-dls merged commit c5c2639 into main Dec 18, 2024
@shihab-dls shihab-dls deleted the 748_convert_transfocator_to_ophyd_async branch December 18, 2024 15:52
is_set_filters_done = True

# The value hasn't changed so assume the device is already set up correctly
async for value in observe_value(self.predicted_vertical_num_lenses):
Copy link
Contributor

Choose a reason for hiding this comment

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

Must: I think there's a potential infinite loop here. See #995

):
# We can only put an integer number of lenses in the beam but the
# calculation in the IOC returns the theoretical float number of lenses
nonlocal is_set_filters_done
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: I always think nonlocal is a bit of a code smell. For example, in this case we could just return the value but I'm also not 100% sure of the purpose of is_set_filters_done

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.

Transfocator: Convert to ophyd-async

4 participants