-
Notifications
You must be signed in to change notification settings - Fork 10
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
Update MX beamlines to use new device factory - part 1 #975
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #975 +/- ##
==========================================
+ Coverage 97.48% 97.52% +0.04%
==========================================
Files 148 148
Lines 6238 6274 +36
==========================================
+ Hits 6081 6119 +38
+ Misses 157 155 -2 ☔ View full report in Codecov by Sentry. |
1e10ec6
to
8096af2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I feel like we should put the part which fixes device_factory
for v1 devices into a separate PR.
Also, for this issue we might as well convert all of the devices in i04, i24 and i23 to use the new instantiation
src/dodal/beamlines/i03.py
Outdated
@device_factory() | ||
@skip_device(lambda: BL == "s03") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on how mx-bluesky/hyperion is handling this:
@device_factory() | |
@skip_device(lambda: BL == "s03") | |
@device_factory(skip = BL == "s03") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or skip = (BL == "s03")
if it's any clearer what is meant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I think we are likely going to remove all this s03
stuff soon as I think we have pretty much given up on the simulator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a separate issue to remove the s03 system tests and I have updated that to remove s03 completely
src/dodal/beamlines/i03.py
Outdated
@device_factory() | ||
@skip_device(lambda: BL == "s03") | ||
def flux(wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False) -> Flux: | ||
def flux(mock: bool = False) -> Flux: | ||
"""Get the i03 flux device, instantiate it if it hasn't already been. | ||
If this is called when already instantiated in i03, it will return the existing object. | ||
""" | ||
return device_instantiation( | ||
Flux, | ||
"flux", | ||
"-MO-FLUX-01:", | ||
wait_for_connection, | ||
fake_with_ophyd_sim, | ||
wait=False, | ||
fake=mock, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be mixing the two device factory types?
) -> Callable[[Callable[[], T]], DeviceInitializationController[T]]: | ||
def decorator(factory: Callable[[], T]) -> DeviceInitializationController[T]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be D, Ophyd-Async only device, the connection logic does not work for Ophyd devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made modifications so that the device factory will now work with ophyd v1 devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you have, if you can't tell that I stopped looking when I reached this point ;)
I thought MX only had the Eiger left on ophyd v1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus a few other minor devices, s4_slits, etc. There is currently a GH ticket to move those across but the Eiger is the main thing, it will probably be a little while yet before that gets moved over to ophyd_async. I thought better to make a start on this.
Once they are moved over, we will be able to get rid of a whole bunch of code including the device_instantiation
stuff.
Fingers quicker than brain and eyes
9c828ca
to
7ec1f74
Compare
…vice_factory calls
…being created in the beamline
ac0ec40
to
e656587
Compare
These changes now in
These changes to follow in subsequent PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The i03 changes look good, but I think there are some lingering changes which you have also made in some other PRs, would you mind taking them out of this one so that we don't end up merging the wrong features from this PR?
wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False | ||
) -> DiamondFilter[I04Filters]: | ||
@device_factory() | ||
def diamond_filter() -> DiamondFilter[I04Filters]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter, but did you mean to take out this change in favour for your i04 PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these lines aren't updated, then test_device_creation
fails without further modifications because device_instantiation
also doesn't work with generics, so then I need to fix device_instantiation
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just one comment
@@ -410,7 +412,27 @@ def is_any_device_factory(func: Callable) -> TypeGuard[AnyDeviceFactory]: | |||
|
|||
|
|||
def is_v2_device_type(obj: type[Any]) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Would be nice to have a test that explicitly checks this works for generics.
Could: Also testing the edge cases of not passing a class etc.
Fixes
for I03, other beamlines to follow in separate PR on top of this one.
Also fixes the following issues:
diamond_filter
was not being instantiated because python generic device types were not recognised as valid device factories.These changes now in follow on PR 846 device factory support for ophyd v1 #984device_factory
did not support usage with sync v1 ophyd devicesSee also mx-bluesky PR
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}