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 - WITH device_factory #722

Closed
wants to merge 94 commits into from
Closed

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

All modified and coverable lines are covered by tests ✅

Project coverage is 97.57%. Comparing base (aab178f) to head (de2d3c6).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #722      +/-   ##
==========================================
+ Coverage   97.51%   97.57%   +0.06%     
==========================================
  Files         152      159       +7     
  Lines        6351     6523     +172     
==========================================
+ Hits         6193     6365     +172     
  Misses        158      158              

☔ 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 Outdated 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 force-pushed the add-i18 branch 3 times, most recently from d9dc74a to 033aec4 Compare August 23, 2024 08:54
@DominicOram
Copy link
Contributor

codecov/patch — 95.27% of diff hit (target 97.51%)
[Details](https://github.com/DiamondLightSource/dodal/pull/722/checks?check_run_id=36218650010)
@codecov
codecov/project Failing after 1s — 97.46% (-0.05%) compared to 497f390

@DiamondJoseph if the beamlines files are config not code, they should be excluded from code coverage, right?

I still think a smoke test would be good for them. i.e. go through and instantiate every device as a mock. I think we have similar code that does this for MX beamlins.

@DiamondJoseph
Copy link
Contributor

@DiamondJoseph if the beamlines files are config not code, they should be excluded from code coverage, right?

I still think a smoke test would be good for them. i.e. go through and instantiate every device as a mock. I think we have similar code that does this for MX beamlins.

We do have that, it just is respecting skip_device so isn't checking the devices that are skipped. Removing the skips from the devices that are functional will help get the numbers back up. There's also 2 missed lines in the ThorLabs table set method, the other new device classes have tests but that does not.

Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

The device_factory suggestions are nits, but unskipping the devices will

a. get the code coverage up
b. mean you don't have to document why they are skipped when they are fully functional
c. give you a wider range of devices when you get to test on the beamline

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/devices/i18/table.py Show resolved Hide resolved
src/dodal/devices/i18/thor_labs_stage.py Outdated Show resolved Hide resolved
@stan-dot stan-dot changed the title add i18 beamline definition add i18 beamline definition - WITH device_factory Jan 27, 2025
Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

Just gotta get the i22 changes that snuck in with the rebase out again then it should be ready

src/dodal/beamlines/i22.py Outdated Show resolved Hide resolved


@device_factory(skip=True)
# VFM uses different IOC than HFM
Copy link
Contributor

Choose a reason for hiding this comment

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

Link the issue for it #1009

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

stan-dot and others added 2 commits January 27, 2025 16:26
Co-authored-by: Joseph Ware <53935796+DiamondJoseph@users.noreply.github.com>
Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

Once the test coverage is fixed this can go in- as discussed, can either add tests to the set methods on those classes, or (since they're not marked as Movables, and the axes are still available as children devices) remove the set method altogether.

@stan-dot
Copy link
Contributor Author

96.92% of diff hit (target 97.51%)
97.50% (-0.02%) compared to aab178f

seriously?

@DiamondJoseph
Copy link
Contributor

96.92% of diff hit (target 97.51%)
97.50% (-0.02%) compared to aab178f

seriously?

Seriously- the target is a moving target that only goes up. All new code has to be at least as tested as everything already in.

@stan-dot
Copy link
Contributor Author

moving target that only goes up

that's very perfectionist

Copy link
Contributor

@DiamondJoseph DiamondJoseph left a comment

Choose a reason for hiding this comment

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

Must: tests need asserts.

@stan-dot
Copy link
Contributor Author

rebasing manually atm

@stan-dot
Copy link
Contributor Author

superceded by #1030

@stan-dot stan-dot closed this Jan 28, 2025
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