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

add i18 beamline definition #722

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

add i18 beamline definition #722

wants to merge 33 commits into from

Conversation

stan-dot
Copy link
Contributor

@stan-dot stan-dot commented Aug 1, 2024

Fixes #709

Instructions to reviewer on how to test:

  1. Do `dodal connect i181
  2. Confirm all the devices expected to work, work

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}

@stan-dot stan-dot added enhancement New feature or request python Pull requests that update Python code i18 labels Aug 1, 2024
@stan-dot stan-dot requested a review from iain-hall August 1, 2024 10:51
@stan-dot stan-dot self-assigned this Aug 1, 2024
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 98.41270% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.70%. Comparing base (fc296b5) to head (d454384).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/dodal/beamlines/i18.py 96.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #722      +/-   ##
==========================================
+ Coverage   95.63%   95.70%   +0.06%     
==========================================
  Files         128      133       +5     
  Lines        5273     5399     +126     
==========================================
+ Hits         5043     5167     +124     
- Misses        230      232       +2     

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

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.

Thanks Stan! Why are there so many skipped devices here?

src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Outdated Show resolved Hide resolved
src/dodal/beamlines/i18.py Show resolved Hide resolved
@stan-dot
Copy link
Contributor Author

stan-dot commented Aug 1, 2024

@DominicOram the devices are skipped as we don't need all of them at the moment, as we roll out the devices following the plans we make, so it's gradual and agile

@stan-dot stan-dot mentioned this pull request Aug 1, 2024
@DominicOram
Copy link
Contributor

so it's gradual and agile

The more agile way to do it would be don't put the devices in at all until you need them otherwise we now have code in that never runs and we don't know if it works.

@stan-dot
Copy link
Contributor Author

stan-dot commented Aug 1, 2024

we need them for the plans in a different repo. also aren't devices skipped all the time depending if they are off or taken out of a beamline physically?

@stan-dot
Copy link
Contributor Author

stan-dot commented Aug 5, 2024

lint error

found 0 vulnerabilities
/home/runner/work/dodal/dodal/src/dodal/devices/i18/sim_motor_set.py
  /home/runner/work/dodal/dodal/src/dodal/devices/i18/sim_motor_set.py:57:12 - error: Cannot assign to attribute "delay" for class "SynAxis"
    Expression of type "float" cannot be assigned to attribute "delay" of class "SynAxis"
      "float" is incompatible with "int" (reportAttributeAccessIssue)
1 error, 0 warnings, 0 informations 

test error:

FAILED tests/devices/i22/test_dcm.py::test_configuration - AssertionError: Expected dcm to produce
{'dcm-bragg-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-bragg-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-energy-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-energy-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_roll-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_roll-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-offset-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-offset-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_pitch-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_pitch-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_roll-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_roll-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-perp-motor_egu': {'value': '', 'timestamp': , 'alarm_severity': }, 'dcm-perp-velocity': {'value': 0.0, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_d_spacing': {'value': 3.13475, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_usage': {'value': 'Bragg', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_type': {'value': 'silicon', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_reflection': {'value': [1, 1, 1], 'timestamp': , 'alarm_severity': }, 'dcm-crystal_2_reflection': {'value': [1, 1, 1], 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_d_spacing': {'value': 3.13475, 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_usage': {'value': 'Bragg', 'timestamp': , 'alarm_severity': }, 'dcm-crystal_1_type': {'value': 'silicon', 'timestamp': , 'alarm_severity': }}
but actually got
{'dcm-bragg-motor_egu': {'value': '', 'timestamp': 217.034084231, 'alarm_severity': 0}, 'dcm-bragg-velocity': {'value': 0.0, 'timestamp': 217.034112413, 'alarm_severity': 0}, 'dcm-energy-motor_egu': {'value': '', 'timestamp': 217.034883664, 'alarm_severity': 0}, 'dcm-energy-velocity': {'value': 0.0, 'timestamp': 217.034907609, 'alarm_severity': 0}, 'dcm-crystal_2_pitch-motor_egu': {'value': '', 'timestamp': 217.03565736, 'alarm_severity': 0}, 'dcm-crystal_2_pitch-velocity': {'value': 0.0, 'timestamp': 217.03567862, 'alarm_severity': 0}, 'dcm-offset-motor_egu': {'value': '', 'timestamp': 217.034355621, 'alarm_severity': 0}, 'dcm-offset-velocity': {'value': 0.0, 'timestamp': 217.034377142, 'alarm_severity': 0}, 'dcm-crystal_1_roll-motor_egu': {'value': '', 'timestamp': 217.035143273, 'alarm_severity': 0}, 'dcm-crystal_1_roll-velocity': {'value': 0.0, 'timestamp': 217.035164924, 'alarm_severity': 0}, 'dcm-crystal_2_roll-motor_egu': {'value': '', 'timestamp': 217.035400046, 'alarm_severity': 0}, 'dcm-crystal_2_roll-velocity': {'value': 0.0, 'timestamp': 217.035421566, 'alarm_severity': 0}, 'dcm-perp-motor_egu': {'value': '', 'timestamp': 217.034619808, 'alarm_severity': 0}, 'dcm-perp-velocity': {'value': 0.0, 'timestamp': 217.034641078, 'alarm_severity': 0}, 'dcm-crystal_2_type': {'value': 'silicon', 'timestamp': 217.028304579, 'alarm_severity': 0}, 'dcm-crystal_1_usage': {'value': 'Bragg', 'timestamp': 217.028175165, 'alarm_severity': 0}, 'dcm-crystal_1_reflection': {'value': [1, 1, 1], 'timestamp': 217.028232263, 'alarm_severity': 0}, 'dcm-crystal_2_reflection': {'value': [1, 1, 1], 'timestamp': 217.028327742, 'alarm_severity': 0}, 'dcm-crystal_1_d_spacing': {'value': 0.31356, 'timestamp': 217.028257851, 'alarm_severity': 0}, 'dcm-crystal_2_d_spacing': {'value': 0.31356, 'timestamp': 217.028350996, 'alarm_severity': 0}, 'dcm-crystal_2_usage': {'value': 'Bragg', 'timestamp': 217.028281545, 'alarm_severity': 0}, 'dcm-crystal_1_type': {'value': 'silicon', 'timestamp': 217.028205542, 'alarm_severity': 0}}
=========== 1 failed, 578 passed, 2 skipped, 27 deselected in 21.10s ===========

@iain-hall I'll try tackling the second one

@DiamondJoseph
Copy link
Contributor

lint error

found 0 vulnerabilities
/home/runner/work/dodal/dodal/src/dodal/devices/i18/sim_motor_set.py
  /home/runner/work/dodal/dodal/src/dodal/devices/i18/sim_motor_set.py:57:12 - error: Cannot assign to attribute "delay" for class "SynAxis"

I would not use the Ophyd (i.e. not ophyd-async) SynAxis

@stan-dot
Copy link
Contributor Author

stan-dot commented Aug 5, 2024

the test_dcm error comes from a failure to correctly read in the 'ANY' mock value.

@stan-dot
Copy link
Contributor Author

stan-dot commented Aug 5, 2024

 src/dodal/beamlines/i18.py:17: in <module>
    from dodal.devices.i18.sim_detector import SimDetector
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/dodal/devices/i18/sim_detector.py:2: in <module>
    from ophyd_async.sim import PatternGenerator
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ophyd_async/sim/__init__.py:1: in <module>
    from .pattern_generator import PatternGenerator
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ophyd_async/sim/pattern_generator.py:14: in <module>
    import h5py
E   ModuleNotFoundError: No module named 'h5py'
____________ ERROR collecting src/dodal/devices/i18/sim_detector.py ____________
ImportError while importing test module '/home/runner/work/dodal/dodal/src/dodal/devices/i18/sim_detector.py'.

that is because in ophyd-async h5py was added only as a dev dependency

@stan-dot
Copy link
Contributor Author

@DiamondJoseph how do I ask for the ophyd-async to be installed with the [sim] dependencies?

the error in question: ModuleNotFoundError: No module named 'h5py'

@DiamondJoseph
Copy link
Contributor

I'll answer on sSlack to avoid everyone getting emails

@stan-dot
Copy link
Contributor Author

waiting until pydantic 2

@stan-dot stan-dot dismissed stale reviews from DiamondJoseph and DominicOram November 11, 2024 12:38

addressed

Comment on lines +5 to +12
class SimDetector:
def __init__(self, name: str, motor: Motor, motor_field: str):
self.name = name
self.motor = motor
self.motor_field = motor_field
self.pattern_generator = PatternGenerator(
saturation_exposure_time=0.1, detector_height=100, detector_width=100
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you're redefining a SimDetector here rather than using the one in ophyd-async that uses the PatternGenerator?

Copy link
Contributor

Choose a reason for hiding this comment

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

The motor field isn't being used at all- is the PatternGenrator meant to read the motor and change its output depending on the value of the motor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure of the details - what do you think @iain-hall ?

Choose a reason for hiding this comment

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

I'm not familiar with PatternGenerator - could be useful. Any simulated detectors would be generally be used for offline testing rather than on the beamline, and we have one already for the diode used in the undulator gap/lookup table generator scan. Maybe we should only have real beamline devices in beamlines/i18.py, and add simulated devices as needed for offline testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the motor fields could be used in a plan with dot notation

src/dodal/devices/i18/table.py Show resolved Hide resolved
@stan-dot stan-dot closed this Nov 13, 2024
@stan-dot
Copy link
Contributor Author

getting an error when upgrading to a higher ophyd-async version

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
blueapi 0.6.1a3.dev20+gb6a47ba5.d20241113 requires bluesky==1.13.0a3, but you have bluesky 1.13 which is incompatible.
blueapi 0.6.1a3.dev20+gb6a47ba5.d20241113 requires event-model==1.21, but you have event-model 1.22.1 which is incompatible.
Successfully installed bluesky-1.13 dls-dodal-1.34.2.dev37+gd454384f1.d20241113 event-model-1.22.1 ophyd-async-0.8.0a4```

@stan-dot stan-dot reopened this Nov 13, 2024
@stan-dot
Copy link
Contributor Author

closed by misclick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request i18 python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make i18 - beamlines files
4 participants