fix(engine): fix labware gripperOffsets not allowing only a default
offset
#13472
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
As introduced in #13186, labware definitions can have a
gripperOffsets
property for providing an offset when picking up and dropping labware to and from that labware. It is required to have adefault
field, used for anything that does not have a specific slot name (e.g.SLOT_C1
).It was noticed in testing though that that
default
key, if there was no corresponding slot name key, was producing aKeyError
because it was always attempting a direct access of the slot name key, regardless if it existed or not. This PR fixes that by first checking for the presence of the key before going for a direct access. This is not currently affecting any existing definition since the only one (opentrons_universal_flat_adapter
) has all possible slot names it can be in in itsgripperOffsets
Test Plan
Tested to make sure that a definition with a
default
only entry worked and did not crash, that gripping to and from a flat adapter still worked as expected, and that gripping to and from a labware with no offset continued to work.Used this protocol with and without adding a default gripper offset to the aluminum block:
Changelog
get_labware_gripper_offsets
to check for presence of key before accessing it fromparsed_offsets
Review requests
Risk assessment
Low, this fixes an exception that was being raised but otherwise does not change the function's behavior.