Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Jul 23, 2024
1 parent bdb1deb commit 5282993
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/_parameter_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from opentrons.protocol_engine.types import (
RunTimeParameter,
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
FileInfo,
)

Expand Down Expand Up @@ -218,7 +218,7 @@ def set_parameters(
parameter.value = validated_value

def initialize_csv_files(
self, run_time_param_file_overrides: CsvRunTimeParamFilesType
self, run_time_param_file_overrides: CSVRunTimeParamFilesType
) -> None:
"""Initializes the files for CSV parameters.
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_engine/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,4 +1068,4 @@ class CSVParameter(RTPBase):
StrictStr, Union[StrictInt, StrictFloat, StrictBool, StrictStr]
] # update value types as more RTP types are added

CsvRunTimeParamFilesType = Mapping[StrictStr, StrictStr]
CSVRunTimeParamFilesType = Mapping[StrictStr, StrictStr]
6 changes: 3 additions & 3 deletions api/src/opentrons/protocol_runner/protocol_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
DeckConfigurationType,
RunTimeParameter,
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from ..protocols.types import PythonProtocol

Expand Down Expand Up @@ -186,7 +186,7 @@ async def load(
protocol_source: ProtocolSource,
python_parse_mode: PythonParseMode,
run_time_param_values: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_files: Optional[CsvRunTimeParamFilesType],
run_time_param_files: Optional[CSVRunTimeParamFilesType],
) -> None:
"""Load a Python or JSONv5(& older) ProtocolSource into managed ProtocolEngine."""
labware_definitions = await protocol_reader.extract_labware_definitions(
Expand Down Expand Up @@ -254,7 +254,7 @@ async def run( # noqa: D102
deck_configuration: DeckConfigurationType,
protocol_source: Optional[ProtocolSource] = None,
run_time_param_values: Optional[PrimitiveRunTimeParamValuesType] = None,
run_time_param_files: Optional[CsvRunTimeParamFilesType] = None,
run_time_param_files: Optional[CSVRunTimeParamFilesType] = None,
python_parse_mode: PythonParseMode = PythonParseMode.NORMAL,
) -> RunResult:
# TODO(mc, 2022-01-11): move load to runner creation, remove from `run`
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_runner/python_protocol_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from opentrons.protocol_engine import ProtocolEngine
from opentrons.protocol_engine.types import (
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from opentrons.protocol_reader import ProtocolSource, ProtocolFileRole
from opentrons.util.broker import Broker
Expand Down Expand Up @@ -165,7 +165,7 @@ def extract_run_parameters(
protocol: PythonProtocol,
parameter_context: ParameterContext,
run_time_param_overrides: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_file_overrides: Optional[CsvRunTimeParamFilesType],
run_time_param_file_overrides: Optional[CSVRunTimeParamFilesType],
) -> Optional[Parameters]:
"""Extract the parameters defined in the protocol, overridden with values for the run."""
return exec_add_parameters(
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_runner/run_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
DeckConfigurationType,
RunTimeParameter,
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from ..protocol_reader import JsonProtocolConfig, PythonProtocolConfig, ProtocolSource
from ..protocols.parse import PythonParseMode
Expand Down Expand Up @@ -325,7 +325,7 @@ async def load(
self,
protocol_source: ProtocolSource,
run_time_param_values: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_files: Optional[CsvRunTimeParamFilesType],
run_time_param_files: Optional[CSVRunTimeParamFilesType],
parse_mode: ParseMode,
) -> None:
"""Load a json/python protocol."""
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/protocols/execution/execute_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from opentrons.protocols.types import PythonProtocol, MalformedPythonProtocolError
from opentrons.protocol_engine.types import (
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)


Expand Down Expand Up @@ -71,7 +71,7 @@ def _raise_pretty_protocol_error(exception: Exception, filename: str) -> None:
def _parse_and_set_parameters(
parameter_context: ParameterContext,
run_time_param_overrides: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_file_overrides: Optional[CsvRunTimeParamFilesType],
run_time_param_file_overrides: Optional[CSVRunTimeParamFilesType],
new_globs: Dict[Any, Any],
filename: str,
) -> Parameters:
Expand Down Expand Up @@ -111,7 +111,7 @@ def exec_add_parameters(
protocol: PythonProtocol,
parameter_context: ParameterContext,
run_time_param_overrides: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_file_overrides: Optional[CsvRunTimeParamFilesType],
run_time_param_file_overrides: Optional[CSVRunTimeParamFilesType],
) -> Optional[Parameters]:
"""Exec the add_parameters function and get the final run time parameters with overrides."""
new_globs: Dict[Any, Any] = {}
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/protocols/analyses_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from opentrons.protocol_engine.types import (
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from opentrons.protocol_engine.errors import ErrorOccurrence

Expand Down Expand Up @@ -40,7 +40,7 @@ async def initialize_analyzer(
analysis_id: str,
protocol_resource: ProtocolResource,
run_time_param_values: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_files: Optional[CsvRunTimeParamFilesType],
run_time_param_files: Optional[CSVRunTimeParamFilesType],
) -> protocol_analyzer.ProtocolAnalyzer:
"""Initialize the protocol analyzer with protocol resource and run time parameter values & fileIds.
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/protocols/analysis_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from opentrons.protocol_engine.types import (
RunTimeParameter,
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from opentrons_shared_data.robot.dev_types import RobotType
from pydantic import BaseModel, Field
Expand Down Expand Up @@ -56,7 +56,7 @@ class AnalysisRequest(BaseModel):
default={},
description="Key-value pairs of primitive run-time parameters defined in a protocol.",
)
runTimeParameterFiles: CsvRunTimeParamFilesType = Field(
runTimeParameterFiles: CSVRunTimeParamFilesType = Field(
default={},
description="Key-fileId pairs of CSV run-time parameters defined in a protocol.",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def get_csv_rtps_by_analysis_id(
with self._sql_engine.begin() as transaction:
results = transaction.execute(statement).all()

csv_rtps: Dict[str, Union[str, None]] = {}
csv_rtps: Dict[str, Optional[str]] = {}
for row in results:
param = CsvParameterResource.from_sql_row(row)
csv_rtps.update({param.parameter_variable_name: param.file_id})
Expand Down Expand Up @@ -349,7 +349,6 @@ async def make_room_and_add(
with self._sql_engine.begin() as transaction:
transaction.execute(delete_primitive_rtp_statement)
transaction.execute(delete_csv_rtp_statement)
transaction.execute(delete_csv_rtp_statement)
transaction.execute(delete_statement)
transaction.execute(insert_statement)
for param in primitive_rtp_resources:
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/protocols/protocol_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from opentrons.protocol_engine.types import (
PrimitiveRunTimeParamValuesType,
RunTimeParameter,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
import opentrons.util.helpers as datetime_helper
from opentrons.protocol_runner import (
Expand Down Expand Up @@ -53,7 +53,7 @@ def get_verified_run_time_parameters(self) -> List[RunTimeParameter]:
async def load_orchestrator(
self,
run_time_param_values: Optional[PrimitiveRunTimeParamValuesType],
run_time_param_files: Optional[CsvRunTimeParamFilesType],
run_time_param_files: Optional[CSVRunTimeParamFilesType],
) -> None:
"""Load runner with the protocol and run time parameter values.
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/protocols/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from opentrons.protocol_engine.types import (
PrimitiveRunTimeParamValuesType,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
)
from opentrons_shared_data.robot import user_facing_robot_type
from opentrons.util.performance_helpers import TrackingFunctions
Expand Down Expand Up @@ -434,7 +434,7 @@ async def _start_new_analysis_if_necessary(
analysis_id: str,
force_analyze: bool,
rtp_values: PrimitiveRunTimeParamValuesType,
rtp_files: CsvRunTimeParamFilesType,
rtp_files: CSVRunTimeParamFilesType,
protocol_resource: ProtocolResource,
analysis_store: AnalysisStore,
analyses_manager: AnalysesManager,
Expand Down
4 changes: 2 additions & 2 deletions robot-server/robot_server/protocols/rtp_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sqlalchemy

from dataclasses import dataclass
from typing import Dict, Callable, Union
from typing import Dict, Callable, Union, Optional

from opentrons.protocols.parameters.types import PrimitiveAllowedTypes

Expand Down Expand Up @@ -74,7 +74,7 @@ class CsvParameterResource:

analysis_id: str
parameter_variable_name: str
file_id: Union[str, None]
file_id: Optional[str]

def to_sql_values(self) -> Dict[str, object]:
"""Return this data as a dict that can be passed to an SQLAlchemy insert."""
Expand Down
4 changes: 2 additions & 2 deletions robot-server/tests/protocols/test_protocols_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
PrimitiveRunTimeParamValuesType,
NumberParameter,
CSVParameter,
CsvRunTimeParamFilesType,
CSVRunTimeParamFilesType,
FileInfo,
)
from opentrons.protocols.api_support.types import APIVersion
Expand Down Expand Up @@ -1654,7 +1654,7 @@ async def test_update_protocol_analyses_with_new_rtp_values(
"dry_run": True,
"mount": "left",
}
rtp_files: CsvRunTimeParamFilesType = {
rtp_files: CSVRunTimeParamFilesType = {
"csv_param": "file-id",
}
protocol_source = ProtocolSource(
Expand Down

0 comments on commit 5282993

Please sign in to comment.