Skip to content

Commit 8112650

Browse files
Merge branch 'edge' into papi_try_liquid_probe
Resolve conflicts in api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py.
2 parents ef0eead + e721bbb commit 8112650

File tree

62 files changed

+948
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+948
-669
lines changed

abr-testing/abr_testing/data_collection/abr_robot_error.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Create ticket for robot with error."""
2-
from typing import List, Tuple, Any, Dict
2+
from typing import List, Tuple, Any, Dict, Optional
33
from abr_testing.data_collection import read_robot_logs, abr_google_drive, get_run_logs
44
import requests
55
import argparse
@@ -18,7 +18,7 @@
1818
def compare_current_trh_to_average(
1919
robot: str,
2020
start_time: Any,
21-
end_time: Any,
21+
end_time: Optional[Any],
2222
protocol_name: str,
2323
storage_directory: str,
2424
) -> str:
@@ -38,27 +38,29 @@ def compare_current_trh_to_average(
3838
df_all_trh = pd.DataFrame(all_trh_data)
3939
# Convert timestamps to datetime objects
4040
df_all_trh["Timestamp"] = pd.to_datetime(
41-
df_all_trh["Timestamp"], format="mixed"
41+
df_all_trh["Timestamp"], format="mixed", utc=True
4242
).dt.tz_localize(None)
4343
# Ensure start_time is timezone-naive
4444
start_time = start_time.replace(tzinfo=None)
45-
end_time = end_time.replace(tzinfo=None)
4645
relevant_temp_rhs = df_all_trh[
47-
(df_all_trh["Robot"] == robot)
48-
& (df_all_trh["Timestamp"] >= start_time)
49-
& (df_all_trh["Timestamp"] <= end_time)
46+
(df_all_trh["Robot"] == robot) & (df_all_trh["Timestamp"] >= start_time)
5047
]
5148
try:
5249
avg_temp = round(mean(relevant_temp_rhs["Temp (oC)"]), 2)
5350
avg_rh = round(mean(relevant_temp_rhs["Relative Humidity (%)"]), 2)
5451
except StatisticsError:
55-
avg_temp = None
56-
avg_rh = None
52+
# If there is one value assign it as the average.
53+
if len(relevant_temp_rhs["Temp (oC)"]) == 1:
54+
avg_temp = relevant_temp_rhs["Temp (oC)"][0]
55+
avg_rh = relevant_temp_rhs["Relative Humidity (%)"][0]
56+
else:
57+
avg_temp = None
58+
avg_rh = None
5759
# Get AVG t/rh of runs w/ same robot & protocol newer than 3 wks old with no errors
5860
weeks_ago_3 = start_time - timedelta(weeks=3)
5961
df_all_run_data = pd.DataFrame(all_run_data)
6062
df_all_run_data["Start_Time"] = pd.to_datetime(
61-
df_all_run_data["Start_Time"], format="mixed"
63+
df_all_run_data["Start_Time"], format="mixed", utc=True
6264
).dt.tz_localize(None)
6365
df_all_run_data["Errors"] = pd.to_numeric(df_all_run_data["Errors"])
6466
df_all_run_data["Average Temp (oC)"] = pd.to_numeric(
@@ -283,7 +285,9 @@ def get_robot_state(
283285
components = match_error_to_component("RABR", reported_string, components)
284286
print(components)
285287
end_time = datetime.now()
288+
print(end_time)
286289
start_time = end_time - timedelta(hours=2)
290+
print(start_time)
287291
# Get current temp/rh compared to historical data
288292
temp_rh_string = compare_current_trh_to_average(
289293
parent, start_time, end_time, "", storage_directory

api-client/src/dataFiles/uploadCsvFile.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ export function uploadCsvFile(
88
config: HostConfig,
99
data: FileData
1010
): ResponsePromise<UploadedCsvFileResponse> {
11-
return request<UploadedCsvFileResponse>(
11+
let formData
12+
13+
if (typeof data !== 'string') {
14+
formData = new FormData()
15+
formData.append('file', data)
16+
} else {
17+
formData = data
18+
}
19+
return request<UploadedCsvFileResponse, FormData | string>(
1220
POST,
1321
'/dataFiles',
14-
null,
15-
config,
16-
data
22+
formData,
23+
config
1724
)
1825
}

api-client/src/protocols/createProtocol.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import { POST, request } from '../request'
22
import type { ResponsePromise } from '../request'
33
import type { HostConfig } from '../types'
44
import type { Protocol } from './types'
5-
import type { RunTimeParameterCreateData } from '../runs'
5+
import type {
6+
RunTimeParameterValuesCreateData,
7+
RunTimeParameterFilesCreateData,
8+
} from '../runs'
69

710
export function createProtocol(
811
config: HostConfig,
912
files: File[],
1013
protocolKey?: string,
1114
protocolKind?: string,
12-
runTimeParameterValues?: RunTimeParameterCreateData
15+
runTimeParameterValues?: RunTimeParameterValuesCreateData,
16+
runTimeParameterFiles?: RunTimeParameterFilesCreateData
1317
): ResponsePromise<Protocol> {
1418
const formData = new FormData()
1519
files.forEach(file => {
@@ -22,6 +26,11 @@ export function createProtocol(
2226
'runTimeParameterValues',
2327
JSON.stringify(runTimeParameterValues)
2428
)
29+
if (runTimeParameterFiles != null)
30+
formData.append(
31+
'runTimeParameterFiles',
32+
JSON.stringify(runTimeParameterFiles)
33+
)
2534

2635
return request<Protocol, FormData>(POST, '/protocols', formData, config)
2736
}

api-client/src/protocols/createProtocolAnalysis.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import { POST, request } from '../request'
33
import type { ProtocolAnalysisSummary } from '@opentrons/shared-data'
44
import type { ResponsePromise } from '../request'
55
import type { HostConfig } from '../types'
6-
import type { RunTimeParameterCreateData } from '../runs'
6+
import type {
7+
RunTimeParameterFilesCreateData,
8+
RunTimeParameterValuesCreateData,
9+
} from '../runs'
710

811
interface CreateProtocolAnalysisData {
9-
runTimeParameterValues: RunTimeParameterCreateData
12+
runTimeParameterValues: RunTimeParameterValuesCreateData
13+
runTimeParameterFiles: RunTimeParameterFilesCreateData
1014
forceReAnalyze: boolean
1115
}
1216

1317
export function createProtocolAnalysis(
1418
config: HostConfig,
1519
protocolKey: string,
16-
runTimeParameterValues?: RunTimeParameterCreateData,
20+
runTimeParameterValues?: RunTimeParameterValuesCreateData,
21+
runTimeParameterFiles?: RunTimeParameterFilesCreateData,
1722
forceReAnalyze?: boolean
1823
): ResponsePromise<ProtocolAnalysisSummary[]> {
1924
const data = {
2025
runTimeParameterValues: runTimeParameterValues ?? {},
26+
runTimeParameterFiles: runTimeParameterFiles ?? {},
2127
forceReAnalyze: forceReAnalyze ?? false,
2228
}
2329
const response = request<

api-client/src/protocols/getCsvFiles.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { v4 as uuidv4 } from 'uuid'
2-
31
// import { GET, request } from '../request'
42

53
// import type { ResponsePromise } from '../request'
@@ -25,18 +23,16 @@ export function getCsvFiles(
2523
config: HostConfig,
2624
protocolId: string
2725
): Promise<{ data: UploadedCsvFilesResponse }> {
28-
const fileIdOne = uuidv4()
29-
const fileIdTwo = uuidv4()
3026
const stub = {
3127
data: {
3228
files: [
3329
{
34-
id: fileIdOne,
30+
id: '1',
3531
createdAt: '2024-06-07T19:19:56.268029+00:00',
3632
name: 'rtp_mock_file1.csv',
3733
},
3834
{
39-
id: fileIdTwo,
35+
id: '2',
4036
createdAt: '2024-06-17T19:19:56.268029+00:00',
4137
name: 'rtp_mock_file2.csv',
4238
},

api-client/src/runs/createRun.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import type { HostConfig } from '../types'
55
import type {
66
Run,
77
LabwareOffsetCreateData,
8-
RunTimeParameterCreateData,
8+
RunTimeParameterValuesCreateData,
9+
RunTimeParameterFilesCreateData,
910
} from './types'
1011

1112
export interface CreateRunData {
1213
protocolId?: string
1314
labwareOffsets?: LabwareOffsetCreateData[]
14-
runTimeParameterValues?: RunTimeParameterCreateData
15+
runTimeParameterValues?: RunTimeParameterValuesCreateData
16+
runTimeParameterFiles?: RunTimeParameterFilesCreateData
1517
}
1618

1719
export function createRun(

api-client/src/runs/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ export interface LabwareOffsetCreateData {
132132
vector: VectorOffset
133133
}
134134

135-
type RunTimeParameterValueType = string | number | boolean | { id: string }
136-
export type RunTimeParameterCreateData = Record<
135+
type RunTimeParameterValuesType = string | number | boolean | { id: string }
136+
export type RunTimeParameterValuesCreateData = Record<
137137
string,
138-
RunTimeParameterValueType
138+
RunTimeParameterValuesType
139139
>
140+
export type RunTimeParameterFilesCreateData = Record<string, string>
140141

141142
export interface CommandData {
142143
data: RunTimeCommand

api/src/opentrons/hardware_control/backends/ot3controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ async def move(
643643
origin=origin, target_list=[move_target]
644644
)
645645
except ZeroLengthMoveError as zme:
646-
log.warning(f"Not moving because move was zero length {str(zme)}")
646+
log.debug(f"Not moving because move was zero length {str(zme)}")
647647
return
648648
moves = movelist[0]
649649
log.info(f"move: machine {target} from {origin} requires {moves}")

api/src/opentrons/hardware_control/ot3api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,6 +2666,8 @@ async def liquid_probe(
26662666
except PipetteLiquidNotFoundError as lnfe:
26672667
error = lnfe
26682668
pos = await self.gantry_position(checked_mount, refresh=True)
2669+
await self.move_to(checked_mount, probe_start_pos + top_types.Point(z=2))
2670+
await self.prepare_for_aspirate(checked_mount)
26692671
await self.move_to(checked_mount, probe_start_pos)
26702672
if error is not None:
26712673
# if we never found liquid raise an error

api/src/opentrons/protocol_api/core/engine/instrument.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def liquid_probe_with_recovery(self, well_core: WellCore, loc: Location) -> None
879879
labware_id = well_core.labware_id
880880
well_name = well_core.get_name()
881881
well_location = WellLocation(
882-
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=0)
882+
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=2)
883883
)
884884
self._engine_client.execute_command(
885885
cmd.LiquidProbeParams(
@@ -898,7 +898,7 @@ def liquid_probe_without_recovery(
898898
labware_id = well_core.labware_id
899899
well_name = well_core.get_name()
900900
well_location = WellLocation(
901-
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=0)
901+
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=2)
902902
)
903903
result = self._engine_client.execute_command_without_recovery(
904904
cmd.LiquidProbeParams(

api/src/opentrons/protocol_api/protocol_context.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,6 @@ def cleanup(self) -> None:
246246
self._unsubscribe_commands()
247247
self._unsubscribe_commands = None
248248

249-
def __del__(self) -> None:
250-
if getattr(self, "_unsubscribe_commands", None):
251-
self._unsubscribe_commands() # type: ignore
252-
253249
@property
254250
@requires_version(2, 0)
255251
def max_speeds(self) -> AxisMaxSpeeds:

api/src/opentrons/protocol_engine/commands/liquid_probe.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ async def execute(self, params: _CommonParams) -> _LiquidProbeExecuteReturn:
143143

144144
try:
145145
z_pos = await self._pipetting.liquid_probe_in_place(
146-
pipette_id=pipette_id, labware_id=labware_id, well_name=well_name
146+
pipette_id=pipette_id,
147+
labware_id=labware_id,
148+
well_name=well_name,
149+
well_location=params.wellLocation,
147150
)
148151
except PipetteLiquidNotFoundError as e:
149152
return DefinedErrorData(

api/src/opentrons/protocol_engine/execution/pipetting.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
InvalidPushOutVolumeError,
1414
InvalidDispenseVolumeError,
1515
)
16-
16+
from opentrons.protocol_engine.types import WellLocation
1717

1818
# 1e-9 µL (1 femtoliter!) is a good value because:
1919
# * It's large relative to rounding errors that occur in practice in protocols. For
@@ -68,6 +68,7 @@ async def liquid_probe_in_place(
6868
pipette_id: str,
6969
labware_id: str,
7070
well_name: str,
71+
well_location: WellLocation,
7172
) -> float:
7273
"""Detect liquid level."""
7374

@@ -176,6 +177,7 @@ async def liquid_probe_in_place(
176177
pipette_id: str,
177178
labware_id: str,
178179
well_name: str,
180+
well_location: WellLocation,
179181
) -> float:
180182
"""Detect liquid level."""
181183
hw_pipette = self._state_view.pipettes.get_hardware_pipette(
@@ -188,7 +190,8 @@ async def liquid_probe_in_place(
188190
pipette_id=pipette_id
189191
)
190192
z_pos = await self._hardware_api.liquid_probe(
191-
mount=hw_pipette.mount, max_z_dist=well_depth - lld_min_height
193+
mount=hw_pipette.mount,
194+
max_z_dist=well_depth - lld_min_height + well_location.offset.z,
192195
)
193196
return float(z_pos)
194197

@@ -290,6 +293,7 @@ async def liquid_probe_in_place(
290293
pipette_id: str,
291294
labware_id: str,
292295
well_name: str,
296+
well_location: WellLocation,
293297
) -> float:
294298
"""Detect liquid level."""
295299
# TODO (pm, 6-18-24): return a value of worth if needed

api/src/opentrons/system/log_control.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
MAX_RECORDS = 100000
1616
DEFAULT_RECORDS = 50000
1717

18-
UNIT_SELECTORS = ["opentrons-robot-server", "opentrons-robot-app"]
18+
UNIT_SELECTORS = [
19+
"opentrons-robot-server",
20+
"opentrons-update-server",
21+
"opentrons-robot-app",
22+
]
1923
SERIAL_SPECIAL = "ALL_SERIAL"
2024
SERIAL_SELECTORS = [
2125
"opentrons-api-serial",

api/tests/opentrons/hardware_control/test_ot3_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ async def test_liquid_probe(
835835
)
836836
fake_max_z_dist = 10.0
837837
await ot3_hardware.liquid_probe(mount, fake_max_z_dist, fake_settings_aspirate)
838-
mock_move_to_plunger_bottom.assert_called_once()
838+
mock_move_to_plunger_bottom.call_count == 2
839839
mock_liquid_probe.assert_called_once_with(
840840
mount,
841841
3.0,
@@ -910,7 +910,7 @@ async def test_multi_liquid_probe(
910910
await ot3_hardware.liquid_probe(
911911
OT3Mount.LEFT, fake_max_z_dist, fake_settings_aspirate
912912
)
913-
assert mock_move_to_plunger_bottom.call_count == 3
913+
assert mock_move_to_plunger_bottom.call_count == 4
914914
mock_liquid_probe.assert_called_with(
915915
OT3Mount.LEFT,
916916
plunger_positions.bottom - plunger_positions.top,
@@ -986,8 +986,8 @@ async def _fake_pos_update_and_raise(
986986
await ot3_hardware.liquid_probe(
987987
OT3Mount.LEFT, fake_max_z_dist, fake_settings_aspirate
988988
)
989-
# assert that it went through 3 passes
990-
assert mock_move_to_plunger_bottom.call_count == 3
989+
# assert that it went through 3 passes and then prepared to aspirate
990+
assert mock_move_to_plunger_bottom.call_count == 4
991991

992992

993993
@pytest.mark.parametrize(

api/tests/opentrons/protocol_api/core/engine/test_instrument_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ def test_liquid_probe_without_recovery(
13741374
cmd.LiquidProbeParams(
13751375
pipetteId=subject.pipette_id,
13761376
wellLocation=WellLocation(
1377-
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=0)
1377+
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=2)
13781378
),
13791379
wellName=well_core.get_name(),
13801380
labwareId=well_core.labware_id,
@@ -1402,7 +1402,7 @@ def test_liquid_probe_with_recovery(
14021402
cmd.LiquidProbeParams(
14031403
pipetteId=subject.pipette_id,
14041404
wellLocation=WellLocation(
1405-
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=0)
1405+
origin=WellOrigin.TOP, offset=WellOffset(x=0, y=0, z=2.0)
14061406
),
14071407
wellName=well_core.get_name(),
14081408
labwareId=well_core.labware_id,

0 commit comments

Comments
 (0)