Skip to content

i15-1: fix robot spinner program race condition - #2229

Merged
DominicOram merged 11 commits into
mainfrom
xtal_bluesky_180_robot_program_fix
Nov 11, 2026
Merged

DominicOram merged 11 commits into
mainfrom
xtal_bluesky_180_robot_program_fix

Conversation

@jacob-williamson

Copy link
Copy Markdown
Contributor

Fixes DiamondLightSource/crystallography-bluesky#180

Instructions to reviewer on how to test:

  1. Do thing x
  2. Confirm thing y happens

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}

@jacob-williamson
jacob-williamson requested a review from a team as a code owner October 7, 2026 14:24
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.30%. Comparing base (1b6abab) to head (cb15647).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2229   +/-   ##
=======================================
  Coverage   99.30%   99.30%           
=======================================
  Files         378      378           
  Lines       14875    14876    +1     
=======================================
+ Hits        14772    14773    +1     
  Misses        103      103           

☔ View full report in Codecov by Harness.
📢 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.

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed, we should instead try and do something like https://github.com/bluesky/ophyd-async/blob/f4e2cd8761af9d80d108ad04a69723306628a678/src/ophyd_async/core/_signal.py#L650 where we start the monitor on the program running first. However, the existing function only works for set, not trigger so I think we need to:

  • Run a camonitor on the beamline to check that this is actually going high
  • If it is add a trigger_and_wait_for_value into ophyd_async, probably using some shared code with the set and use it here
  • If it isn't it might be worth discussing with controls or we just do this?

@jacob-williamson

jacob-williamson commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

I tested this out and the program is so quick that usually we don't get any change on the PROGRAM_RUNNING PV. Have created a controls issue, for now should we just do this?

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

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 to tidy up

ProgramRunning.PROGRAM_RUNNING,
timeout=self.PROGRAM_STARTED_RUNNING_TIMEOUT,
)
await wait_for_value(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: Its seems weird to wait for the program to finish in the case where we don't wait for the program to start.

Comment on lines +292 to +295
await self._trigger_program_and_wait_for_complete(
signal_to_set, wait_for_program_running=False
)
await wait_for_value(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could: Could: Given https://github.com/DiamondLightSource/dodal/pull/2229/changes#r4513019538 I think it might be better to just call await trigger here and keep _trigger_program_and_wait_for_complete as it was before?

self.current_sample.position.set(0),
)

async def _set_spinner_state(self, new_state: SpinnerState) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could: Would be nice to have a test that this doesn't wait for the program

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we could make it so the the mock behaviour is to not have the program running flag go high on stopping the spinner? But it's not a very obvious test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'll change the mock behaviour to not put the program running flag high when setting spinner state

set_mock_value(robot.puck_sel, 0) # Set initial position
set_mock_value(robot.pos_sel, 0) # Set initial position

callback_on_mock_put(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: I think these would be better put in the MockRobot

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great, thank you!

@DominicOram
DominicOram merged commit 76aaff4 into main Nov 11, 2026
11 checks passed
@DominicOram
DominicOram deleted the xtal_bluesky_180_robot_program_fix branch November 11, 2026 10:03
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.

Robot spinner race condition

2 participants