Skip to content
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(api): remove feature-flag dependency from calibration_storage #13833

Merged
merged 12 commits into from
Oct 31, 2023
Merged
69 changes: 7 additions & 62 deletions api/src/opentrons/calibration_storage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from opentrons import config

from .ot3 import ot3_gripper_offset
from .ot3 import gripper_offset
from .ot2 import mark_bad_calibration

# TODO these functions are only used in robot server. We should think about moving them and/or
Expand All @@ -23,79 +21,26 @@
delete_robot_deck_attitude,
)

if config.feature_flags.enable_ot3_hardware_controller():
from .ot3.pipette_offset import (
save_pipette_calibration,
clear_pipette_offset_calibrations,
get_pipette_offset,
delete_pipette_offset_file,
)
from .ot3.tip_length import (
clear_tip_length_calibration,
create_tip_length_data,
save_tip_length_calibration,
tip_lengths_for_pipette,
load_tip_length_calibration,
delete_tip_length_calibration,
)
from .ot3 import models
from .ot3.module_offset import (
save_module_calibration,
clear_module_offset_calibrations,
get_module_offset,
delete_module_offset_file,
load_all_module_offsets,
)
else:
from .ot2.pipette_offset import (
save_pipette_calibration,
clear_pipette_offset_calibrations,
get_pipette_offset,
delete_pipette_offset_file,
)
from .ot2.tip_length import (
clear_tip_length_calibration,
create_tip_length_data,
save_tip_length_calibration,
tip_lengths_for_pipette,
load_tip_length_calibration,
delete_tip_length_calibration,
)
from .ot2 import models # type: ignore[no-redef]
from . import ot2, ot3, helpers

__all__ = [
"helpers",
# deck calibration functions
"save_robot_deck_attitude",
"get_robot_deck_attitude",
"delete_robot_deck_attitude",
"save_robot_belt_attitude",
"get_robot_belt_attitude",
"delete_robot_belt_attitude",
# pipette calibration functions
"save_pipette_calibration",
"get_pipette_offset",
"clear_pipette_offset_calibrations",
"delete_pipette_offset_file",
# tip length calibration functions
"clear_tip_length_calibration",
"create_tip_length_data",
"save_tip_length_calibration",
"tip_lengths_for_pipette",
"delete_tip_length_calibration",
"load_tip_length_calibration",
# module calibration functions
"save_module_calibration",
"clear_module_offset_calibrations",
"get_module_offset",
"delete_module_offset_file",
"load_all_module_offsets",
# functions only used in robot server
"_save_custom_tiprack_definition",
"get_custom_tiprack_definition_for_tlc",
"get_all_pipette_offset_calibrations",
"get_all_tip_length_calibrations",
# file exports
"models",
"ot3_gripper_offset",
"gripper_offset",
"mark_bad_calibration",
# Platform specific submodules
"ot2",
"ot3",
]
28 changes: 26 additions & 2 deletions api/src/opentrons/calibration_storage/ot2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
from . import (
models as ot2_models,
models,
mark_bad_calibration,
)
from .pipette_offset import (
save_pipette_calibration,
clear_pipette_offset_calibrations,
get_pipette_offset,
delete_pipette_offset_file,
)

from .tip_length import (
clear_tip_length_calibration,
create_tip_length_data,
save_tip_length_calibration,
tip_lengths_for_pipette,
load_tip_length_calibration,
delete_tip_length_calibration,
)

__all__ = [
"ot2_models",
"models",
"mark_bad_calibration",
"save_pipette_calibration",
"clear_pipette_offset_calibrations",
"get_pipette_offset",
"delete_pipette_offset_file",
"clear_tip_length_calibration",
"create_tip_length_data",
"save_tip_length_calibration",
"tip_lengths_for_pipette",
"load_tip_length_calibration",
"delete_tip_length_calibration",
]
45 changes: 40 additions & 5 deletions api/src/opentrons/calibration_storage/ot3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
from . import (
models as ot3_models,
gripper_offset as ot3_gripper_offset,
models,
gripper_offset as gripper_offset,
)
from .pipette_offset import (
save_pipette_calibration,
clear_pipette_offset_calibrations,
get_pipette_offset,
delete_pipette_offset_file,
)
from .tip_length import (
clear_tip_length_calibration,
create_tip_length_data,
save_tip_length_calibration,
tip_lengths_for_pipette,
load_tip_length_calibration,
delete_tip_length_calibration,
)
from .module_offset import (
save_module_calibration,
clear_module_offset_calibrations,
get_module_offset,
delete_module_offset_file,
load_all_module_offsets,
)


__all__ = [
"ot3_models",
"ot3_gripper_offset",
"models",
"gripper_offset",
"save_pipette_calibration",
"clear_pipette_offset_calibrations",
"get_pipette_offset",
"delete_pipette_offset_file",
"clear_tip_length_calibration",
"create_tip_length_data",
"save_tip_length_calibration",
"tip_lengths_for_pipette",
"load_tip_length_calibration",
"delete_tip_length_calibration",
"save_module_calibration",
"clear_module_offset_calibrations",
"get_module_offset",
"delete_module_offset_file",
"load_all_module_offsets",
]
23 changes: 18 additions & 5 deletions api/src/opentrons/config/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,27 @@
from pathlib import Path
from typing import NamedTuple, Dict, Set

from opentrons.config import IS_ROBOT
from opentrons.config import IS_ROBOT, feature_flags as ff
from opentrons.calibration_storage import (
delete_robot_deck_attitude,
clear_tip_length_calibration,
clear_pipette_offset_calibrations,
ot3_gripper_offset,
gripper_offset,
)

if ff.enable_ot3_hardware_controller():
fsinapi marked this conversation as resolved.
Show resolved Hide resolved
from opentrons.calibration_storage.ot3.pipette_offset import (
clear_pipette_offset_calibrations,
)
from opentrons.calibration_storage.ot3.tip_length import (
clear_tip_length_calibration,
)
else:
from opentrons.calibration_storage.ot2.pipette_offset import (
clear_pipette_offset_calibrations,
)
from opentrons.calibration_storage.ot2.tip_length import (
clear_tip_length_calibration,
)


DATA_BOOT_D = Path("/data/boot.d")
AUTHORIZED_KEYS = Path(os.path.expanduser("~/.ssh/authorized_keys"))
Expand Down Expand Up @@ -163,7 +176,7 @@ def reset_pipette_offset() -> None:


def reset_gripper_offset() -> None:
ot3_gripper_offset.clear_gripper_calibration_offsets()
gripper_offset.clear_gripper_calibration_offsets()


def reset_tip_length_calibrations() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from opentrons.config.robot_configs import default_pipette_offset

from opentrons import calibration_storage
from opentrons.calibration_storage import ot2 as calibration_storage
from opentrons.calibration_storage import types, helpers
from opentrons.types import Mount, Point
from opentrons.hardware_control.types import OT3Mount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from opentrons.calibration_storage import (
types as cal_top_types,
ot3_gripper_offset,
gripper_offset,
)
from opentrons.hardware_control.types import OT3Mount

Expand Down Expand Up @@ -122,7 +122,7 @@ def load_gripper_calibration_offset(
status=cal_top_types.CalibrationStatus(),
)
if gripper_id and ff.enable_ot3_hardware_controller():
grip_offset_data = ot3_gripper_offset.get_gripper_calibration_offset(gripper_id)
grip_offset_data = gripper_offset.get_gripper_calibration_offset(gripper_id)
if grip_offset_data:
return GripperCalibrationOffset(
offset=grip_offset_data.offset,
Expand All @@ -141,7 +141,7 @@ def save_gripper_calibration_offset(
gripper_id: typing.Optional[str], delta: Point
) -> None:
if gripper_id and ff.enable_ot3_hardware_controller():
ot3_gripper_offset.save_gripper_calibration(delta, gripper_id)
gripper_offset.save_gripper_calibration(delta, gripper_id)


def check_instrument_offset_reasonability(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import pytest
import typing
import opentrons
import importlib

from opentrons.types import Point
from opentrons.calibration_storage import (
types as cs_types,
ot3_gripper_offset as gripper,
)
from opentrons.calibration_storage.ot3 import gripper_offset as gripper, models


@pytest.fixture
Expand Down Expand Up @@ -62,9 +60,6 @@ def test_get_gripper_calibration(
"""
Test ability to get a gripper calibration schema.
"""
importlib.reload(opentrons.calibration_storage)
from opentrons.calibration_storage import models

gripper_data = gripper.get_gripper_calibration_offset("gripper1")
assert gripper_data is not None
assert gripper_data == models.v1.InstrumentOffsetModel(
Expand Down
Loading