-
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
feat(api): add liquid class in PAPI #16506
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9f66b48
change tip type to tip rack
sanni-t a2f3f48
add definition loading
sanni-t 47f8848
update load_definition, add definition validation tests
sanni-t fd80cd1
add LiquidClass and define_liquid_class, add tests
sanni-t abca372
small changes, more tests
sanni-t b237bcf
added display name and updated liquid class name
sanni-t 641c160
make pretty js
sanni-t 06c26b8
add integration test
sanni-t fa1ebea
added feature flag
sanni-t f4322b4
addressed review comments
sanni-t f1e8ffa
add feature flag migration, update tests
sanni-t 29795ab
remove needlessly fancy filtering with lambda function
sanni-t 538939b
required field is 'tiprack' not 'tipType'
sanni-t 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
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
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
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
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 |
---|---|---|
|
@@ -7,6 +7,10 @@ | |
from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3 | ||
from opentrons_shared_data.labware.labware_definition import LabwareDefinition | ||
from opentrons_shared_data.labware.types import LabwareDefinition as LabwareDefDict | ||
from opentrons_shared_data import liquid_classes | ||
from opentrons_shared_data.liquid_classes.liquid_class_definition import ( | ||
LiquidClassSchemaV1, | ||
) | ||
from opentrons_shared_data.pipette.types import PipetteNameType | ||
from opentrons_shared_data.robot.types import RobotType | ||
|
||
|
@@ -51,7 +55,7 @@ | |
|
||
from ... import validation | ||
from ..._types import OffDeckType | ||
from ..._liquid import Liquid | ||
from ..._liquid import Liquid, LiquidClass | ||
from ...disposal_locations import TrashBin, WasteChute | ||
from ..protocol import AbstractProtocol | ||
from ..labware import LabwareLoadParams | ||
|
@@ -103,6 +107,7 @@ def __init__( | |
str, Union[ModuleCore, NonConnectedModuleCore] | ||
] = {} | ||
self._disposal_locations: List[Union[Labware, TrashBin, WasteChute]] = [] | ||
self._defined_liquid_class_defs_by_name: Dict[str, LiquidClassSchemaV1] = {} | ||
self._load_fixed_trash() | ||
|
||
@property | ||
|
@@ -747,6 +752,23 @@ def define_liquid( | |
), | ||
) | ||
|
||
def define_liquid_class(self, name: str) -> LiquidClass: | ||
"""Define a liquid class for use in transfer functions.""" | ||
try: | ||
# Check if we have already loaded this liquid class' definition | ||
liquid_class_def = self._defined_liquid_class_defs_by_name[name] | ||
except KeyError: | ||
try: | ||
# Fetching the liquid class data from file and parsing it | ||
# is an expensive operation and should be avoided. | ||
# Calling this often will degrade protocol execution performance. | ||
liquid_class_def = liquid_classes.load_definition(name) | ||
self._defined_liquid_class_defs_by_name[name] = liquid_class_def | ||
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. Shouldnt this be 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. good catch |
||
raise ValueError("Liquid class definition not found") | ||
|
||
return LiquidClass.create(liquid_class_def) | ||
|
||
def get_labware_location( | ||
self, labware_core: LabwareCore | ||
) -> Union[str, LabwareCore, ModuleCore, NonConnectedModuleCore, OffDeckType]: | ||
|
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
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
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
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 more of a style preference, but I much prefer having list comprehensions here rather than lambda expressions. Not only are they more efficient (no
list
call and function calls), I find them easier to read.