-
Notifications
You must be signed in to change notification settings - Fork 178
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
refactor(shared-data, robot-server, api): Pipette configuration architecture refactor to organize by nozzle map and tip type #15250
Merged
CaseyBatten
merged 32 commits into
edge
from
pipette_configuration_architecture_by_nozzle_map
Jun 11, 2024
Merged
Changes from 11 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
09b2e01
pipette configuration values adjusted by nozzle map first pass
CaseyBatten af38b12
engine updates to support nested map and tip type configurations and …
CaseyBatten cd11ee0
tip overlap conversion to source from physical definition tree
CaseyBatten 7d3d79e
Merge branch 'edge' into pipette_configuration_architecture_by_nozzle…
CaseyBatten 6004a9a
tip overlap by nozzle configuration engine infrastructure
CaseyBatten 350ebd0
tip overlap by dict fix for v3_6 p1000 and engine updates to reflect …
CaseyBatten 45d2899
single channel definition updates
CaseyBatten d2d8b47
ninety six channel definition updates
CaseyBatten cf13f9b
eight channel v 1 0 upgrade
CaseyBatten 4364c08
eight channel pipette definition updates
CaseyBatten 8247821
test run with 8ch p50 and format fixes and error catching for configu…
CaseyBatten 939995f
relocate valid map key to nozzle map
CaseyBatten a21f592
linting fixes test corrections and remove impossible nozzle configura…
CaseyBatten 88f4f66
pipette handler test corrections
CaseyBatten 6e390b4
mutable configurations updates
CaseyBatten 2e03700
front to back bias for 8ch and single ch map naming convention
CaseyBatten 2e19184
single channel SingleA1 map naming
CaseyBatten 5e67680
Merge branch 'edge' into pipette_configuration_architecture_by_nozzle…
CaseyBatten 1505f11
tip overlap versioning definition migration
CaseyBatten 9a3d2d6
consolidate pipette config value logic and addition of tip overlap ve…
CaseyBatten 8f4040b
addition of MissingConfigurationData error code and robot server fixes
CaseyBatten 8ca7773
typescript type updates and schema definition updates
CaseyBatten 9e23a59
hardware testing updates to utilize configurations by nozzle map
CaseyBatten 36aef87
step generation updates
CaseyBatten 49e2967
js pipette test data
CaseyBatten 397c4ac
error formatting fix
CaseyBatten f4fa638
Merge branch 'edge' into pipette_configuration_architecture_by_nozzle…
CaseyBatten 6ff32cc
single channel p1000 3_7 schema migration
CaseyBatten 4ee4853
js test updates for single channel p1000 pipette v3_7
CaseyBatten 4bda970
schema clarifications and unit test for map consistency
CaseyBatten 6702599
typo correction
CaseyBatten d33c225
pipette data provider error update
CaseyBatten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
PipetteModelVersionType, | ||
PipetteNameType, | ||
PipetteLiquidPropertiesDefinition, | ||
PressFitPickUpTipConfiguration, | ||
) | ||
from opentrons_shared_data.pipette import ( | ||
load_data as load_pipette_data, | ||
|
@@ -112,6 +113,11 @@ def __init__( | |
pipette_channels=config.channels, | ||
pipette_version=config.version, | ||
) | ||
self._valid_nozzle_maps = load_pipette_data.load_valid_nozzle_maps( | ||
self._pipette_model.pipette_type, | ||
self._pipette_model.pipette_channels, | ||
self._pipette_model.pipette_version, | ||
) | ||
self._nozzle_offset = self._config.nozzle_offset | ||
self._nozzle_manager = ( | ||
nozzle_manager.NozzleConfigurationManager.build_from_config(self._config) | ||
|
@@ -148,7 +154,9 @@ def __init__( | |
self._active_tip_settings.default_blowout_flowrate.default | ||
) | ||
|
||
self._tip_overlap_lookup = self._liquid_class.tip_overlap_dictionary | ||
self._tip_overlap_dictionary = ( | ||
self.get_nominal_tip_overlap_dictionary_by_configuration() | ||
) | ||
|
||
if use_old_aspiration_functions: | ||
self._pipetting_function_version = PIPETTING_FUNCTION_FALLBACK_VERSION | ||
|
@@ -217,7 +225,7 @@ def pipette_offset(self) -> PipetteOffsetByPipetteMount: | |
|
||
@property | ||
def tip_overlap(self) -> Dict[str, float]: | ||
return self._tip_overlap_lookup | ||
return self._tip_overlap_dictionary | ||
|
||
@property | ||
def channels(self) -> pip_types.PipetteChannelType: | ||
|
@@ -290,7 +298,10 @@ def reset_state(self) -> None: | |
self.active_tip_settings.default_blowout_flowrate.default | ||
) | ||
|
||
self._tip_overlap_lookup = self.liquid_class.tip_overlap_dictionary | ||
self._tip_overlap_dictionary = ( | ||
self.get_nominal_tip_overlap_dictionary_by_configuration() | ||
) | ||
|
||
self._nozzle_manager = ( | ||
nozzle_manager.NozzleConfigurationManager.build_from_config(self._config) | ||
) | ||
|
@@ -520,6 +531,111 @@ def remove_tip(self) -> None: | |
def has_tip(self) -> bool: | ||
return self._has_tip | ||
|
||
def _get_matching_approved_nozzle_map(self) -> str: | ||
for map_key in self._valid_nozzle_maps.maps.keys(): | ||
if self._valid_nozzle_maps.maps[map_key] == list( | ||
self._nozzle_manager.current_configuration.map_store.keys() | ||
): | ||
return map_key | ||
raise ValueError( | ||
"Nozzle Configuration does not match any approved map layout for the current pipette." | ||
) | ||
|
||
def get_pick_up_speed_by_configuration( | ||
self, | ||
config: PressFitPickUpTipConfiguration, | ||
) -> float: | ||
approved_map = None | ||
for map_key in self._valid_nozzle_maps.maps.keys(): | ||
if self._valid_nozzle_maps.maps[map_key] == list( | ||
self._nozzle_manager.current_configuration.map_store.keys() | ||
): | ||
approved_map = map_key | ||
if approved_map is None: | ||
raise ValueError( | ||
"Pick up tip speed request error. Nozzle Configuration does not match any approved map layout for the current pipette." | ||
) | ||
|
||
try: | ||
return config.configuration_by_nozzle_map[approved_map][ | ||
pip_types.PipetteTipType(self._liquid_class.max_volume).name | ||
].speed | ||
except KeyError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should have these errors be enumerated errors defined in shared data using an error code, like a new 4000-series "missing configuration data" or something |
||
default = config.configuration_by_nozzle_map[approved_map].get("default") | ||
if default is not None: | ||
return default.speed | ||
raise KeyError( | ||
f"Default tip type configuration values do not exist for Nozzle Map {approved_map}." | ||
) | ||
|
||
def get_pick_up_distance_by_configuration( | ||
self, | ||
config: PressFitPickUpTipConfiguration, | ||
) -> float: | ||
approved_map = self._get_matching_approved_nozzle_map() | ||
|
||
try: | ||
return config.configuration_by_nozzle_map[approved_map][ | ||
pip_types.PipetteTipType(self._liquid_class.max_volume).name | ||
].distance | ||
except KeyError: | ||
default = config.configuration_by_nozzle_map[approved_map].get("default") | ||
if default is not None: | ||
return default.distance | ||
raise KeyError( | ||
f"Default tip type configuration values do not exist for Nozzle Map {approved_map}." | ||
) | ||
|
||
def get_pick_up_current_by_configuration( | ||
self, | ||
config: PressFitPickUpTipConfiguration, | ||
) -> float: | ||
approved_map = self._get_matching_approved_nozzle_map() | ||
|
||
try: | ||
return config.configuration_by_nozzle_map[approved_map][ | ||
pip_types.PipetteTipType(self._liquid_class.max_volume).name | ||
].current | ||
except KeyError: | ||
default = config.configuration_by_nozzle_map[approved_map].get("default") | ||
if default is not None: | ||
return default.current | ||
raise KeyError( | ||
f"Default tip type configuration values do not exist for Nozzle Map {approved_map}." | ||
) | ||
|
||
def get_nominal_tip_overlap_dictionary_by_configuration( | ||
self, | ||
) -> Dict[str, float]: | ||
for config in ( | ||
self._config.pick_up_tip_configurations.press_fit, | ||
self._config.pick_up_tip_configurations.cam_action, | ||
): | ||
if not config: | ||
continue | ||
approved_map = self._get_matching_approved_nozzle_map() | ||
|
||
try: | ||
return config.configuration_by_nozzle_map[approved_map][ | ||
pip_types.PipetteTipType(self._liquid_class.max_volume).name | ||
].tip_overlap_dictionary | ||
except KeyError: | ||
try: | ||
default = config.configuration_by_nozzle_map[approved_map].get( | ||
"default" | ||
) | ||
if default is not None: | ||
return default.tip_overlap_dictionary | ||
raise KeyError( | ||
f"Default tip type configuration values do not exist for Nozzle Map {approved_map}." | ||
) | ||
except KeyError: | ||
# No valid key found for the approved nozzle map under this configuration - try the next | ||
continue | ||
raise CommandPreconditionViolated( | ||
message="No valid tip overlap dictionary identified.", | ||
) | ||
|
||
# Cache max is chosen somewhat arbitrarily. With a float is input we don't | ||
# want this to unbounded. | ||
@functools.lru_cache(maxsize=100) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a whole lot to be doing just here, and it adds this error category. instead of doing this, let's tell the nozzle manager what map key it's using and then we can look up the configuration based on that directly.