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

Start an ophyd-async OAV #815

Merged
merged 43 commits into from
Oct 14, 2024
Merged

Start an ophyd-async OAV #815

merged 43 commits into from
Oct 14, 2024

Conversation

noemifrisina
Copy link
Collaborator

Starts the work for #716

Creates a first version of an ophyd-async OAV, for the moment including only the zoom controller and the code to get the microns per pixels and beam position out of the parameter files.

Instructions to reviewer on how to test:

  1. Run tests

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}

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.12%. Comparing base (4cc0811) to head (d309b1b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #815      +/-   ##
==========================================
+ Coverage   95.03%   95.12%   +0.09%     
==========================================
  Files         119      120       +1     
  Lines        4810     4901      +91     
==========================================
+ Hits         4571     4662      +91     
  Misses        239      239              

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

@noemifrisina noemifrisina marked this pull request as ready for review October 7, 2024 17:05
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Great start, thanks. Some comments in code. I also wondered if it was a bit cleaner to treat everything as tuples, see https://github.com/DiamondLightSource/dodal/tree/716_ophyd_async_oav_suggestion. I think it makes the functions in OAV a bit cleaner but I'm not 100% sure I like the implicit assumption that 0 == x and 1 == y. What do you think?

Additionally, it would be good to have some extra tests more specific to oav_parameters that directly test OAVConfig rather than test it through the device.

StaticVisitPathProvider(
BL,
Path("/dls/i24/data/2024/cm37275-4/bluesky"),
# client=RemoteDirectoryServiceClient("http://i24-control:8088/api"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: I think we can remove this as it defaults to it.

Comment on lines 164 to 165
drv_suffix="CAM:",
hdf_suffix="HDF5:",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: I would have these just default in the device and not needed to be passed in, I don't see when we will change them

"thst": epics_signal_r(str, f"{prefix}MP:SELECT.THST"),
"frst": epics_signal_r(str, f"{prefix}MP:SELECT.FRST"),
"fvst": epics_signal_r(str, f"{prefix}MP:SELECT.FVST"),
"sxst": epics_signal_r(str, f"{prefix}MP:SELECT.SXST"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: We can get these dynamically with self.level.describe() e.g.

from dodal.devices.oav.oav_async import ZoomController
from bluesky.run_engine import RunEngine
from ophyd_async.core import DeviceCollector
import asyncio

RE = RunEngine()

with DeviceCollector():
    zoom_controller = ZoomController("BL03I-EA-OAV-01:FZOOM:")

async def get_values():
    description = await zoom_controller.level.describe()
    print(description["zoom_controller-level"]["choices"])

asyncio.run(get_values())


_bl_prefix = prefix.split("-")[0]
self.zoom_controller = ZoomController(f"{_bl_prefix}-EA-OAV-01:FZOOM:", name)
# TODO This will actually come from the MJPG but for now...
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: Can we put this an issue please?

prefix: str,
path_provider: PathProvider,
drv_suffix: str,
hdf_suffix: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

hdf_suffix doesn't really make much sense for us, we never write these to hdf. Maybe this means we should be making it optional in the AravisDetector. I guess we should discuss.

Comment on lines 249 to 251
_zoom = str(_get_element_as_float(node, "level"))
_um_pix_x = _get_element_as_float(node, "micronsPerXPixel")
_um_pix_y = _get_element_as_float(node, "micronsPerYPixel")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: _ is usually used to indicate this is a private variable but the fact it's scoped to the function means it has to be private so this feels redundant

Comment on lines 142 to 146
self.micronsPerXPixel = create_hardware_backed_soft_signal(
float,
lambda: self._get_microns_per_pixel("x"),
)
self.micronsPerYPixel = 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.

Should: Can we make these camel case please?

beam_y - vertical_pixels,
)

async def connect(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: I think it might be ok to do all this on init rather than connect

@noemifrisina
Copy link
Collaborator Author

I think it makes the functions in OAV a bit cleaner but I'm not 100% sure I like the implicit assumption that 0 == x and 1 == y.

It does look tidier, but I don't really like the assumption either. I guess we could use an IntEnum just to make it a little less implicit?

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Great, thank you!

@noemifrisina noemifrisina merged commit 73cbfc9 into main Oct 14, 2024
18 checks passed
@noemifrisina noemifrisina deleted the 716_oav-to-ophyd-async branch October 14, 2024 16:25
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.

2 participants