-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fixes for ophyd async types mega merge #858
Conversation
65bf6a3
to
303869f
Compare
1b5cfd6
to
9b8109d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #858 +/- ##
==========================================
- Coverage 95.61% 95.60% -0.02%
==========================================
Files 125 125
Lines 5246 5229 -17
==========================================
- Hits 5016 4999 -17
Misses 230 230 ☔ View full report in Codecov by Sentry. |
def6e22
to
3732d8f
Compare
uri = kwargs.get("uri") | ||
uri_or_prefix = uri or prefix | ||
kwargs_with_prefix_or_uri = dict(kwargs) |
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.
please better naming or typing, that uri_or_prefix: str for clarity
3732d8f
to
e02138f
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.
Great, thanks, a few comments in code. Additionally, I'm getting some errors on dodal connect i03
:
Traceback (most recent call last):
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/core/_device.py", line 146, in connect
await self._connect_task
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/core/_signal.py", line 66, in connect
await self.backend.connect(timeout)
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/epics/signal/_aioca.py", line 264, in connect
self.converter = make_converter(self.datatype, self.initial_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/scratch/ffv81422/mx_bluesky_hyperion_merge/mx-bluesky/.venv/lib/python3.11/site-packages/ophyd_async/epics/signal/_aioca.py", line 209, in make_converter
raise TypeError(
TypeError: BL03I-EA-XSP3-01:ARR1:ArrayData with inferred datatype Array1D[np.float64] cannot be coerced to numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
thawer: TypeError: Cannot set the parent of <ophyd_async.core._signal.SignalRW object at 0x7fe77afded90> to be <dodal.devices.thawer.ThawingTimer object at 0x7fe77b0146d0>: it is already a child of <dodal.devices.thawer.Thawer object at 0x7fe77aff5990>
panda: TypeError: HDFPanda.__init__() got an unexpected keyword argument 'uri'
I think the other errors from dodal connect i03
are related to real hardware being off. I'm also seeing errors on dodal connect i22
which I think are related to this. Basically, it would be good to go through all the beamlines and try dodal connect
with this. Annoyingly dodal connect --all
is broken (#875) so this will be a painful job.
I haven't dug into the changes for #814 (comment) as I will need to review in conjunction with DiamondLightSource/mx-bluesky#475
src/dodal/devices/attenuator.py
Outdated
@@ -24,23 +24,23 @@ class Attenuator(StandardReadable, Movable): | |||
read from the device it is also fractional""" | |||
|
|||
def __init__(self, prefix: str, name: str = ""): | |||
self._calculated_filter_states: DeviceVector[SignalR[int]] = DeviceVector( | |||
self.calculated_filter_states: DeviceVector[SignalR[int]] = DeviceVector( |
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: Can we put all the signals in here back to private? I think we don't want people accidentally using them rather than the set
of this Device
@@ -27,7 +27,7 @@ class AperturePosition(BaseModel): | |||
aperture_z: float | |||
scatterguard_x: float | |||
scatterguard_y: float | |||
radius: float | None = Field(json_schema_extra={"units": "µm"}, default=None) | |||
radius: float = Field(json_schema_extra={"units": "µm"}, default=0.0) |
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: We need to be a bit careful here as in the robot load position no aperture is selected and so asking what the aperture radius is is meaningless. I think using 0 to signify it is fine, or we could maybe use float('nan')
but we should probably write it in some docstrings here and be aware of it in the downstream code
src/dodal/devices/focusing_mirror.py
Outdated
self.actual_v = epics_signal_r(int, prefix + "R") | ||
self.setpoint_v = epics_signal_rw(int, prefix + "D") | ||
self.demand_accepted = epics_signal_r(MirrorVoltageDemand, prefix + "DSEV") |
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: As above, I think keep these private to avoid people setting then directly
{ | ||
Source.ROI.value: OAVSource(f"{prefix}MJPG:", "roi"), | ||
Source.FULL_SCREEN.value: OAVSource(f"{prefix}XTAL:", "fullscreen"), | ||
} | ||
) | ||
self.selected_source = soft_signal_rw(Source) | ||
self.selected_source = soft_signal_rw(int) |
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: I think we should probably make this a string enum then. It will tidy up the log messages etc. too
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.
Unfortunately the integer is required for the use of DeviceVector
src/dodal/devices/oav/utils.py
Outdated
timeout = yield from bps.rd(ophyd_pin_tip_detection.validity_timeout) | ||
raise PinNotFoundException(f"No pin found after {timeout} seconds") | ||
|
||
return found_tip # type: ignore | ||
return Pixel((int(found_tip[0]), int(found_tip[1]))) # type: ignore |
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.
Nit: I don't think we need the type ignore now?
@@ -45,7 +44,7 @@ async def set(self, value: ZebraShutterState): | |||
raise UserWarning( | |||
f"Tried to set shutter to {value.value} but the shutter is in auto mode." | |||
) | |||
await self._manual_position_setpoint.set(value) | |||
await self.manual_position_setpoint.set(value) |
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: I think we should keep this private to encourage the set
to be used
tests/devices/i22/test_dcm.py
Outdated
@pytest.mark.skip( | ||
reason="https://github.com/bluesky/ophyd-async/pull/594 assert_configuration() on numpy arrays is " | ||
"broken" | ||
) |
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: Is this still true? If so it needs a link to an open issue to fix/workaround
src/dodal/devices/i10/i10_apple2.py
Outdated
@@ -196,17 +198,17 @@ def __init__( | |||
""" | |||
super().__init__(name=name) | |||
with self.add_children_as_readables(): |
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.
with self.add_children_as_readables(): |
I think we can remove this now.
I also have a question, what is the best way to have read behave like it use to? For example in this case, when read is call it will read the readable in both id_ref and pgm_ref as well as i10_apple2.
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 removed it. I think that what you want is probably not going to be supported by ophyd-async because it would make it difficult for users to reason about the expected behaviour of devices if their read
behaviour differs from their publicly expressed device/signal hierarchy.
I believe @dperl-dls is going to write a style guide about the best way to structure devices and I think it will probably advise not to have overlapping composite 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.
Thanks, one minor comment but I still need to review the Zocalo
changes in the context of DiamondLightSource/mx-bluesky#553
@@ -26,7 +25,7 @@ class ZebraShutter(StandardReadable, Movable): | |||
Internally in the zebra there are two AND gates, one for manual control and one for | |||
automatic control. A soft input (aliased to control_mode) will switch between | |||
which of these AND gates to use. For the manual gate the shutter is then controlled | |||
by a different soft input (aliased to _manual_position_setpoint). Both these AND | |||
by a different soft input (aliased to manual_position_setpoint). Both these AND |
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.
Nit: This doesn't match the signal name now
85d8ac0
to
2ed8908
Compare
…s where the children were all instances of Reference
c5baf3f
to
5ce9e43
Compare
Fixes breakages in dodal for bluesky/ophyd-async#594
Note this fix depends on #814Note this fix now incorporates #814
See also mx-bluesky PR DiamondLightSource/mx-bluesky#593
Instructions to reviewer on how to test:
StrictEnum
/SubsetEnum
is appropriateChecks for reviewer
dodal connect ${BEAMLINE}