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

(DiamondLightSource/hyperion#1464) Change topup gating to prevent gating with long exposures #674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rtuck99
Copy link
Contributor

@rtuck99 rtuck99 commented Jul 16, 2024

Fixes DiamondLightSource/hyperion#1464

After conversation with beamline staff, rather than implement the same solution as exists currently in GDA, the following behaviour is implemented:

  • Topup gating in hyperion is now controlled by the following parameters in beamlineParameters:
    • dodal_topup_threshold_exposure_s (default 120) controls the exposure time at which hyperion gates topups
    • dodal_topup_end_delay_s (default 1) controls an additional adjustable delay after topup end to ensure no accidental overlap with topup due to timing inaccurancies and can be adjusted to allow further time for settling if necessary.

To determine whether a topup is performed:

  • If the COUNTDOWN PV != -1 and Synchrotron mode is User or Special then the gating steps are followed as below, otherwise we proceed with the scan as normal.
  • The exposure duration, plus an operation-specific setup time (currently default 10s for rotation scans and 30s for grid scans) is compared with the time remaining to topup (ENDCOUNTDN PV), if it is more than this then the scan may be delayed, otherwise the scan is not delayed.
  • The exposure duration is compared with dodal_topup_threshold_exposure_s and if it is less than this the scan is delayed, otherwise it is considered a long duration scan which can be performed during topup and is not delayed.
  • If after the above checks have determined a delay is required, we then wait for ENDCOUNTDN - COUNTDOWN + dodal_topup_end_delay_s seconds rounded up to the nearest second.

Note:

It is expected that the location of these parameters is temporary until at some later stage they are moved into the config server.

Instructions to reviewer on how to test:

  1. Attempt normal and long-duration scans during topup and check the above happens.
  2. Tests pass

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}

@rtuck99 rtuck99 force-pushed the hyperion_1464_rotation_scans_timeout_at_long_exposures branch from 5b6b6a0 to 15b4379 Compare July 23, 2024 09:35
@rtuck99 rtuck99 marked this pull request as ready for review July 23, 2024 09:36
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.23%. Comparing base (025efb0) to head (15b4379).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #674      +/-   ##
==========================================
+ Coverage   94.17%   94.23%   +0.06%     
==========================================
  Files         108      108              
  Lines        4306     4319      +13     
==========================================
+ Hits         4055     4070      +15     
+ Misses        251      249       -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.

Great, thanks. Some optional comments to help with working out why this the behaviour in the future. Otherwise looks good.

@@ -23,15 +39,28 @@ def _gating_permitted(machine_mode: SynchrotronMode):
return False


def _delay_to_avoid_topup(total_run_time, time_to_topup):
def _delay_to_avoid_topup(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: We could have a docstring on this function explaining why we need the threshold and why sometimes wait and sometimes don't (basically just summarising this issue).

# For planned exposures less than this value, wait for topup to finish instead of
# collecting throughout topup.
THRESHOLD_EXPOSURE_S = "dodal_topup_threshold_exposure_s"
# Additional safety margin to wait after the end of topup.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: A little bit more detail on why we need the safety margin would be good.

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.

Rotation scans timeout at long exposures due to top up wait
2 participants