Skip to content

Conversation

@srishtysajeev
Copy link
Contributor

@srishtysajeev srishtysajeev commented Sep 26, 2025

Fixes #1567

Instructions to reviewer on how to test:

  1. Check for any mistakes within the code / comments
  2. Check that the tests are correct
  3. Check that the tests run

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}

@srishtysajeev srishtysajeev requested a review from a team as a code owner September 26, 2025 13:24
@srishtysajeev srishtysajeev changed the title 1567 move scintillator to beam Add ability to move scintillator in to beam for i04 Sep 26, 2025
@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.09%. Comparing base (7b14545) to head (78ba2f0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1583   +/-   ##
=======================================
  Coverage   99.08%   99.09%           
=======================================
  Files         275      275           
  Lines       10098    10114   +16     
=======================================
+ Hits        10006    10022   +16     
  Misses         92       92           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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, some comments in code but mostly quite minor

@DominicOram
Copy link
Contributor

From discussion on i03 I think we may have got the collision with the aperture/scatterguard wrong here, see DiamondLightSource/mx-bluesky#1354

Copy link
Contributor Author

@srishtysajeev srishtysajeev left a comment

Choose a reason for hiding this comment

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

From beamline testing need to add awaits such as:

 
-    def _check_aperture_parked(self):
+    async def _check_aperture_parked(self):
         if (
-            self._aperture_scatterguard().selected_aperture.get_value()
+            await self._aperture_scatterguard().selected_aperture.get_value()
             != ApertureValue.PARKED
         ):
             raise ValueError(
-                "Cannot move scintillator out if aperture/scatterguard is not parked"
+                f"Cannot move scintillator out if aperture/scatterguard is not parked. Position is currently {await self._aperture_scatterguard().selected_aperture.get_value()}"
             )
 
     async def _set_selected_position(self, position: InOut) -> None:
-        self._check_aperture_parked()
+        await self._check_aperture_parked()
         match position:
             case InOut.OUT:
                 await self.y_mm.set(self._scintillator_out_yz_mm[0])

@srishtysajeev srishtysajeev force-pushed the 1567_move_scintillator_to_beam branch from ba148ee to 9ac45ee Compare November 4, 2025 16:16
@rtuck99
Copy link
Contributor

rtuck99 commented Nov 6, 2025

Need to make sure this doesn't undo #1625 by blocking a set if nothing needs to happen

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, a couple of comments

await assert_value(scintillator.z_mm.user_setpoint, 101.5115)


async def test_given_aperture_scatterguard_not_parked_when_set_to_out_position_then_exception_raised(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: This function says it checks out but it actually checks both. A better way to do this would be to use pytest.mark.parametrize to test each thing in isolation

Comment on lines 17 to 20
"""
See https://opencv24-python-tutorials.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_morphological_ops/py_morphological_ops.html
for description of functions below.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: This seems unrelated so technically shouldn't be part of this PR but it's just some docs so fine to keep here

@srishtysajeev srishtysajeev force-pushed the 1567_move_scintillator_to_beam branch from 9f52097 to 21b3eca Compare November 17, 2025 11:18
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, thanks

Copy link
Contributor Author

@srishtysajeev srishtysajeev left a comment

Choose a reason for hiding this comment

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

addint comment

raise ValueError(
f"Cannot move scintillator if aperture/scatterguard is not parked. Position is currently {await self._aperture_scatterguard().selected_aperture.get_value()}"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is self._aperture_scatterguard().selected_aperture.get_value(), what we want here? I noticed that sometimes the error gives out Large or Small rather than an actual position - is that expected, and should I be testing that the correct error message is outputted?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's correct, the positions it can have are Large/Medium/Small

@srishtysajeev srishtysajeev enabled auto-merge (squash) November 17, 2025 15:31
@srishtysajeev srishtysajeev merged commit bc36da8 into main Nov 17, 2025
10 checks passed
@srishtysajeev srishtysajeev deleted the 1567_move_scintillator_to_beam branch November 17, 2025 16:17
CoePaul pushed a commit that referenced this pull request Nov 18, 2025
* Add scint into beam + change Enum comment to be be more descriptive compared to just In and Out.


---------

Co-authored-by: Dominic Oram <[email protected]>
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.

Add ability to move scintillator into beam

5 participants