From 7677f9a2f30dcd6bfd5b0e929c4a8e757ed4a772 Mon Sep 17 00:00:00 2001 From: Jamey H Date: Thu, 7 Dec 2023 17:18:33 -0500 Subject: [PATCH] fix(app, api): expose failOnNotHomed parameter for save_position command (#14139) Drop tip flows require saving pipette positions without homing the plunger axis (we definitely do not want to home the plunger). The save_position command should optionally expose a failOnNotHomed parameter to prevent an error from being thrown when the plunger is not homed. --- .../opentrons/protocol_engine/commands/save_position.py | 8 +++++++- .../protocol_engine/commands/test_save_position.py | 5 +---- app/src/organisms/DropTipWizard/index.tsx | 1 + .../http_api/protocols/test_v6_json_upload.tavern.yaml | 2 ++ .../protocols/test_v8_json_upload_flex.tavern.yaml | 2 ++ .../protocols/test_v8_json_upload_ot2.tavern.yaml | 2 ++ shared-data/command/schemas/8.json | 6 ++++++ shared-data/command/types/gantry.ts | 1 + 8 files changed, 22 insertions(+), 5 deletions(-) diff --git a/api/src/opentrons/protocol_engine/commands/save_position.py b/api/src/opentrons/protocol_engine/commands/save_position.py index 5e38b902058..a45937a73e8 100644 --- a/api/src/opentrons/protocol_engine/commands/save_position.py +++ b/api/src/opentrons/protocol_engine/commands/save_position.py @@ -26,6 +26,9 @@ class SavePositionParams(BaseModel): description="An optional ID to assign to this command instance. " "Auto-assigned if not defined.", ) + failOnNotHomed: Optional[bool] = Field( + True, descrption="Require all axes to be homed before saving position." + ) class SavePositionResult(BaseModel): @@ -58,8 +61,11 @@ def __init__( async def execute(self, params: SavePositionParams) -> SavePositionResult: """Check the requested pipette's current position.""" position_id = self._model_utils.ensure_id(params.positionId) + fail_on_not_homed = ( + params.failOnNotHomed if params.failOnNotHomed is not None else True + ) x, y, z = await self._gantry_mover.get_position( - pipette_id=params.pipetteId, fail_on_not_homed=True + pipette_id=params.pipetteId, fail_on_not_homed=fail_on_not_homed ) return SavePositionResult( diff --git a/api/tests/opentrons/protocol_engine/commands/test_save_position.py b/api/tests/opentrons/protocol_engine/commands/test_save_position.py index e31f44c779c..99b52a4cd42 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_save_position.py +++ b/api/tests/opentrons/protocol_engine/commands/test_save_position.py @@ -35,10 +35,7 @@ async def test_save_position_implementation( subject = SavePositionImplementation( model_utils=mock_model_utils, gantry_mover=mock_gantry_mover ) - params = SavePositionParams( - pipetteId="abc", - positionId="123", - ) + params = SavePositionParams(pipetteId="abc", positionId="123", failOnNotHomed=True) decoy.when(mock_model_utils.ensure_id("123")).then_return("456") diff --git a/app/src/organisms/DropTipWizard/index.tsx b/app/src/organisms/DropTipWizard/index.tsx index d533c82ea8f..29a9e755a4a 100644 --- a/app/src/organisms/DropTipWizard/index.tsx +++ b/app/src/organisms/DropTipWizard/index.tsx @@ -292,6 +292,7 @@ export const DropTipWizardComponent = ( commandType: 'savePosition' as const, params: { pipetteId: MANAGED_PIPETTE_ID, + failOnNotHomed: false, }, }, ] diff --git a/robot-server/tests/integration/http_api/protocols/test_v6_json_upload.tavern.yaml b/robot-server/tests/integration/http_api/protocols/test_v6_json_upload.tavern.yaml index f9e1198bc32..13af0f78d84 100644 --- a/robot-server/tests/integration/http_api/protocols/test_v6_json_upload.tavern.yaml +++ b/robot-server/tests/integration/http_api/protocols/test_v6_json_upload.tavern.yaml @@ -507,6 +507,7 @@ stages: status: succeeded params: pipetteId: pipetteId + failOnNotHomed: true result: positionId: !anystr position: @@ -539,6 +540,7 @@ stages: params: pipetteId: pipetteId positionId: positionId + failOnNotHomed: true result: positionId: positionId position: diff --git a/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_flex.tavern.yaml b/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_flex.tavern.yaml index a2ec1a8bb6a..636cd055090 100644 --- a/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_flex.tavern.yaml +++ b/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_flex.tavern.yaml @@ -542,6 +542,7 @@ stages: status: succeeded params: pipetteId: pipetteId + failOnNotHomed: true result: positionId: !anystr position: @@ -574,6 +575,7 @@ stages: params: pipetteId: pipetteId positionId: positionId + failOnNotHomed: true result: positionId: positionId position: diff --git a/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_ot2.tavern.yaml b/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_ot2.tavern.yaml index 954551ebd53..48fb8200d61 100644 --- a/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_ot2.tavern.yaml +++ b/robot-server/tests/integration/http_api/protocols/test_v8_json_upload_ot2.tavern.yaml @@ -539,6 +539,7 @@ stages: status: succeeded params: pipetteId: pipetteId + failOnNotHomed: true result: positionId: !anystr position: @@ -571,6 +572,7 @@ stages: params: pipetteId: pipetteId positionId: positionId + failOnNotHomed: true result: positionId: positionId position: diff --git a/shared-data/command/schemas/8.json b/shared-data/command/schemas/8.json index 6b46c318856..b3398ca54eb 100644 --- a/shared-data/command/schemas/8.json +++ b/shared-data/command/schemas/8.json @@ -2205,6 +2205,12 @@ "title": "Positionid", "description": "An optional ID to assign to this command instance. Auto-assigned if not defined.", "type": "string" + }, + "failOnNotHomed": { + "title": "Failonnothomed", + "default": true, + "descrption": "Require all axes to be homed before saving position.", + "type": "boolean" } }, "required": ["pipetteId"] diff --git a/shared-data/command/types/gantry.ts b/shared-data/command/types/gantry.ts index c119b63dd39..435188d948d 100644 --- a/shared-data/command/types/gantry.ts +++ b/shared-data/command/types/gantry.ts @@ -156,6 +156,7 @@ interface MoveRelativeParams { interface SavePositionParams { pipetteId: string // pipette to use in measurement positionId?: string // position ID, auto-assigned if left blank + failOnNotHomed?: boolean // Defaults to true if blank. Require every possible axis to be homed to save. } interface HomeParams {