From 15c05704ea307b11e1b5729f9381c0a8acaea1f3 Mon Sep 17 00:00:00 2001 From: amit lissack Date: Tue, 4 May 2021 12:46:56 -0400 Subject: [PATCH] SyncClient.load_pipette does not need pipette_id argument. --- .../opentrons/protocol_api_experimental/protocol_context.py | 1 - api/src/opentrons/protocol_engine/clients/sync_client.py | 4 +--- api/src/opentrons/protocol_engine/commands/load_pipette.py | 2 +- api/src/opentrons/protocol_engine/execution/equipment.py | 2 +- .../protocol_api_experimental/test_protocol_context.py | 3 --- .../opentrons/protocol_engine/clients/test_sync_client.py | 2 -- .../opentrons/protocol_engine/commands/test_load_pipette.py | 1 - .../opentrons/protocol_engine/state/test_pipette_state.py | 1 - robot-server/tests/service/session/models/test_command.py | 2 -- .../session_types/live_protocol/test_command_executor.py | 1 - 10 files changed, 3 insertions(+), 16 deletions(-) diff --git a/api/src/opentrons/protocol_api_experimental/protocol_context.py b/api/src/opentrons/protocol_api_experimental/protocol_context.py index 69094db3fd8..e28c16336c3 100644 --- a/api/src/opentrons/protocol_api_experimental/protocol_context.py +++ b/api/src/opentrons/protocol_api_experimental/protocol_context.py @@ -47,7 +47,6 @@ def load_pipette( # noqa: D102 result = self._engine_client.load_pipette( pipette_name=PipetteName(pipette_name), mount=Mount(mount), - pipette_id=None, ) return PipetteContext( diff --git a/api/src/opentrons/protocol_engine/clients/sync_client.py b/api/src/opentrons/protocol_engine/clients/sync_client.py index 5c2550fdf93..5ed204f833c 100644 --- a/api/src/opentrons/protocol_engine/clients/sync_client.py +++ b/api/src/opentrons/protocol_engine/clients/sync_client.py @@ -1,6 +1,6 @@ """Synchronous ProtocolEngine client module.""" from uuid import uuid4 -from typing import cast, Optional +from typing import cast from opentrons.types import MountType @@ -51,13 +51,11 @@ def load_pipette( self, pipette_name: PipetteName, mount: MountType, - pipette_id: Optional[str], ) -> commands.LoadPipetteResult: """Execute a LoadPipetteRequest and return the result.""" request = commands.LoadPipetteRequest( pipetteName=pipette_name, mount=mount, - pipetteId=pipette_id ) result = self._transport.execute_command( request=request, diff --git a/api/src/opentrons/protocol_engine/commands/load_pipette.py b/api/src/opentrons/protocol_engine/commands/load_pipette.py index eee5d37e62a..ddef913759b 100644 --- a/api/src/opentrons/protocol_engine/commands/load_pipette.py +++ b/api/src/opentrons/protocol_engine/commands/load_pipette.py @@ -23,7 +23,7 @@ class LoadPipetteRequest(BaseModel): description="The mount the pipette should be present on.", ) pipetteId: Optional[str] = Field( - ..., + None, description="An optional ID to assign to this pipette. If None, an ID " "will be generated." ) diff --git a/api/src/opentrons/protocol_engine/execution/equipment.py b/api/src/opentrons/protocol_engine/execution/equipment.py index 46f3b4fa0a9..8d788f4c67c 100644 --- a/api/src/opentrons/protocol_engine/execution/equipment.py +++ b/api/src/opentrons/protocol_engine/execution/equipment.py @@ -108,7 +108,7 @@ async def load_pipette( except RuntimeError as e: raise FailedToLoadPipetteError(str(e)) from e - pipette_id = pipette_id if pipette_id else \ + pipette_id = pipette_id if pipette_id is not None else \ self._resources.id_generator.generate_id() return LoadedPipette(pipette_id=pipette_id) diff --git a/api/tests/opentrons/protocol_api_experimental/test_protocol_context.py b/api/tests/opentrons/protocol_api_experimental/test_protocol_context.py index 7de01094761..4ce67ff9014 100644 --- a/api/tests/opentrons/protocol_api_experimental/test_protocol_context.py +++ b/api/tests/opentrons/protocol_api_experimental/test_protocol_context.py @@ -50,7 +50,6 @@ def test_load_pipette( engine_client.load_pipette( pipette_name=PipetteName.P300_SINGLE, mount=Mount.LEFT, - pipette_id=None, ) ).then_return(commands.LoadPipetteResult(pipetteId="pipette-id")) @@ -72,7 +71,6 @@ def test_load_instrument( engine_client.load_pipette( pipette_name=PipetteName.P300_MULTI, mount=Mount.LEFT, - pipette_id=None ) ).then_return(commands.LoadPipetteResult(pipetteId="left-pipette-id")) @@ -80,7 +78,6 @@ def test_load_instrument( engine_client.load_pipette( pipette_name=PipetteName.P300_SINGLE, mount=Mount.RIGHT, - pipette_id=None ) ).then_return(commands.LoadPipetteResult(pipetteId="right-pipette-id")) diff --git a/api/tests/opentrons/protocol_engine/clients/test_sync_client.py b/api/tests/opentrons/protocol_engine/clients/test_sync_client.py index 31e29f27877..9db7e78eb33 100644 --- a/api/tests/opentrons/protocol_engine/clients/test_sync_client.py +++ b/api/tests/opentrons/protocol_engine/clients/test_sync_client.py @@ -92,7 +92,6 @@ def test_load_pipette( request = commands.LoadPipetteRequest( pipetteName=PipetteName.P300_SINGLE, mount=MountType.RIGHT, - pipetteId=None, ) expected_result = commands.LoadPipetteResult(pipetteId="abc123") @@ -104,7 +103,6 @@ def test_load_pipette( result = subject.load_pipette( pipette_name=PipetteName.P300_SINGLE, mount=MountType.RIGHT, - pipette_id=None, ) assert result == expected_result diff --git a/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py b/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py index d1e7736d3d0..388c7ecc841 100644 --- a/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py +++ b/api/tests/opentrons/protocol_engine/commands/test_load_pipette.py @@ -15,7 +15,6 @@ def test_load_pipette_request() -> None: request = LoadPipetteRequest( pipetteName=PipetteName.P300_SINGLE, mount=MountType.LEFT, - pipetteId=None ) assert request.pipetteName == "p300_single" diff --git a/api/tests/opentrons/protocol_engine/state/test_pipette_state.py b/api/tests/opentrons/protocol_engine/state/test_pipette_state.py index 5359d134f1b..bb5208d3ff8 100644 --- a/api/tests/opentrons/protocol_engine/state/test_pipette_state.py +++ b/api/tests/opentrons/protocol_engine/state/test_pipette_state.py @@ -25,7 +25,6 @@ def load_pipette_command(now: datetime) -> CompletedLoadLabware: request=cmd.LoadPipetteRequest( pipetteName=PipetteName.P300_SINGLE, mount=MountType.LEFT, - pipetteId=None, ), result=cmd.LoadPipetteResult(pipetteId="pipette-id"), created_at=now, diff --git a/robot-server/tests/service/session/models/test_command.py b/robot-server/tests/service/session/models/test_command.py index a42f2467179..f5515d85b4c 100644 --- a/robot-server/tests/service/session/models/test_command.py +++ b/robot-server/tests/service/session/models/test_command.py @@ -63,7 +63,6 @@ def test_not_empty(): assert request.data.data == pe_commands.LoadPipetteRequest( pipetteName="p10_single", mount=MountType.LEFT, - pipetteId=None, ) dt = datetime(2000, 1, 1) @@ -84,7 +83,6 @@ def test_not_empty(): assert response.data == pe_commands.LoadPipetteRequest( pipetteName="p10_single", mount=MountType.LEFT, - pipetteId=None, ) assert response.id == "id" assert response.createdAt == dt diff --git a/robot-server/tests/service/session/session_types/live_protocol/test_command_executor.py b/robot-server/tests/service/session/session_types/live_protocol/test_command_executor.py index 1a968c28956..9773d0fabee 100644 --- a/robot-server/tests/service/session/session_types/live_protocol/test_command_executor.py +++ b/robot-server/tests/service/session/session_types/live_protocol/test_command_executor.py @@ -136,7 +136,6 @@ async def test_load_instrument(command_executor, mock_protocol_engine): request_body = pe_commands.LoadPipetteRequest( pipetteName="p10_single", mount=MountType.LEFT, - pipetteId=None, ) protocol_engine_response = pe_commands.CompletedCommand(