Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Oct 17, 2024
1 parent fa1ebea commit f4322b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/_liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class LiquidClass:
def create(cls, liquid_class_definition: LiquidClassSchemaV1) -> "LiquidClass":
"""Liquid class factory method."""

return LiquidClass(
return cls(
_name=liquid_class_definition.liquidClassName,
_display_name=liquid_class_definition.displayName,
_by_pipette_setting=liquid_class_definition.byPipette,
Expand Down
6 changes: 4 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from __future__ import annotations
from typing import Dict, Optional, Type, Union, List, Tuple, TYPE_CHECKING

from opentrons_shared_data.liquid_classes import LiquidClassDefinitionDoesNotExist

from opentrons.protocol_engine import commands as cmd
from opentrons.protocol_engine.commands import LoadModuleResult
from opentrons_shared_data.deck.types import DeckDefinitionV5, SlotDefV3
Expand Down Expand Up @@ -764,8 +766,8 @@ def define_liquid_class(self, name: str) -> LiquidClass:
# 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:
raise ValueError("Liquid class definition not found")
except LiquidClassDefinitionDoesNotExist:
raise ValueError(f"Liquid class definition not found for '{name}'.")

return LiquidClass.create(liquid_class_def)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def test_liquid_class_creation_and_property_fetching(
== 100
)

with pytest.raises(ValueError):
with pytest.raises(
ValueError,
match="No properties found for p300_multi in fixture_glycerol50 liquid class",
):
glycerol_50.get_for(pipette_right.name, tiprack.load_name)

with pytest.raises(AttributeError):
Expand All @@ -46,6 +49,9 @@ def test_liquid_class_creation_and_property_fetching(
with pytest.raises(AttributeError):
glycerol_50.display_name = "bar" # type: ignore

with pytest.raises(ValueError, match="Liquid class definition not found"):
protocol_context.define_liquid_class("non-existent-liquid")


def test_liquid_class_feature_flag() -> None:
"""It should raise a not implemented error without the allowLiquidClass flag set."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class LiquidClassDefinitionDoesNotExist(Exception):
"""Specified liquid class' definition does not exist."""
"""Specified liquid class definition does not exist."""


# TODO (spp, 2024-10-16): update the path once definitions are added
Expand Down

0 comments on commit f4322b4

Please sign in to comment.