fix(api): lock instrument cache during calibration #12577
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
If a desktop app is on the same network as a robot, it will poll the
GET /instruments
endpoint to get the current attached instruments. This process involves loading any saved calibration offsets in the hardware controller. If the robot is currently calibrating an axis, this is a very bad thing! The calibration offsets are cleared at the beginning of calibration and must remain cleared for the entirety of calibration.This PR adds a simple asyncio lock to disable the
cache_instruments
function. The calibration functions acquire the lock for their entire duration, thus preventing the robot from accidentally applying unwanted offsets.Test Plan
Push this to a robot and ping the
GET /instruments
endpoint both during calibration & before/after calibration, while monitoring the logs withjournalctl --follow | grep "opentrons-api\["
The endpoint should always return valid data as well.
Changelog
cache_instruments
functionReview requests
Risk assessment