Skip to content

Commit c7bcbad

Browse files
authored
feat(step-generation): cosmetic updates to load_labware and touch_tip (#17834)
# Overview 1) For the OT-2, we were generating `load_labware` code like: ``` protocol.load_labware( "opentrons_96_tiprack_300ul", "2", namespace="opentrons", version=1, ) ``` The bare string `"2"` can be a bit perplexing to someone reading this code. So I'm changing it to `location="2"`. 2) The Python `touch_tip` command is short and can fit on one line. And having it on one line looks better next to the surrounding `aspirate()`/`dispense()` calls that have pretty long lines. So now `touch_tip` will look like this: ``` pipette_left.touch_tip(well_plate_2["A1"], v_offset=-1, speed=5) ``` ## Test Plan and Hands on Testing Updated unit tests. Tried the generated output in `simulate`, which passes. ## Risk assessment Low, Python export is behind feature flag.
1 parent 5f383ef commit c7bcbad

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

protocol-designer/src/file-data/__tests__/createFile.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ def run(protocol: protocol_api.ProtocolContext):
137137
# Load Labware:
138138
mock_python_name_1 = protocol.load_labware(
139139
"fixture_trash",
140-
"12",
140+
location="12",
141141
label="Trash",
142142
namespace="fixture",
143143
version=1,
144144
)
145145
mock_python_name_2 = protocol.load_labware(
146146
"fixture_tiprack_10_ul",
147-
"1",
147+
location="1",
148148
label="Opentrons 96 Tip Rack 10 µL",
149149
namespace="fixture",
150150
version=1,
151151
)
152152
mock_python_name_3 = protocol.load_labware(
153153
"fixture_96_plate",
154-
"7",
154+
location="7",
155155
label="NEST 96 Well Plate 100 µL PCR Full Skirt",
156156
namespace="fixture",
157157
version=1,

protocol-designer/src/file-data/__tests__/pythonFile.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ well_plate_2 = magnetic_block_2.load_labware(
238238
)
239239
well_plate_3 = protocol.load_labware(
240240
"fixture_96_plate",
241-
"C2",
241+
location="C2",
242242
label="sample plate",
243243
namespace="fixture",
244244
version=1,

protocol-designer/src/file-data/selectors/pythonFile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function getLoadLabware(
163163
`${formatPyStr(parameters.loadName)}`,
164164
...(!onModule && !onAdapter
165165
? [
166-
`${formatPyStr(
166+
`location=${formatPyStr(
167167
labwareSlot === 'offDeck' ? OFF_DECK : labwareSlot
168168
)}`,
169169
]

step-generation/src/__tests__/touchTip.test.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ describe('touchTip', () => {
5858
},
5959
])
6060
expect(res.python).toBe(
61-
`
62-
mockPythonName.touch_tip(
63-
mockPythonName["A1"],
64-
v_offset=10,
65-
speed=10,
66-
mm_from_edge=0.2,
67-
)`.trimStart()
61+
`mockPythonName.touch_tip(mockPythonName["A1"], v_offset=10, speed=10, mm_from_edge=0.2)`
6862
)
6963
})
7064

@@ -82,11 +76,7 @@ mockPythonName.touch_tip(
8276
const res = getSuccessResult(result)
8377

8478
expect(res.python).toBe(
85-
`
86-
mockPythonName.touch_tip(
87-
mockPythonName["A1"],
88-
v_offset=10,
89-
)`.trimStart()
79+
`mockPythonName.touch_tip(mockPythonName["A1"], v_offset=10)`
9080
)
9181
})
9282

step-generation/src/commandCreators/atomic/touchTip.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatPyStr, indentPyLines, uuid } from '../../utils'
1+
import { formatPyStr, uuid } from '../../utils'
22
import { noTipOnPipette, pipetteDoesNotExist } from '../../errorCreators'
33
import type { CreateCommand, TouchTipParams } from '@opentrons/shared-data'
44
import type { CommandCreator, CommandCreatorError } from '../../types'
@@ -56,16 +56,14 @@ export const touchTip: CommandCreator<TouchTipAtomicParams> = (
5656
invariantContext.labwareEntities[labwareId].pythonName
5757

5858
const pythonArgs = [
59-
`${labwarePythonName}[${formatPyStr(wellName)}],`,
60-
`v_offset=${zOffsetFromTop},`,
61-
...(speed != null ? [`speed=${speed},`] : []),
62-
...(mmFromEdge != null ? [`mm_from_edge=${mmFromEdge},`] : []),
59+
`${labwarePythonName}[${formatPyStr(wellName)}]`,
60+
`v_offset=${zOffsetFromTop}`,
61+
...(speed != null ? [`speed=${speed}`] : []),
62+
...(mmFromEdge != null ? [`mm_from_edge=${mmFromEdge}`] : []),
6363
]
6464

6565
// TODO: add mmFromEdge to python and commandCreator
66-
const python = `${pipettePythonName}.touch_tip(\n${indentPyLines(
67-
pythonArgs.join('\n')
68-
)}\n)`
66+
const python = `${pipettePythonName}.touch_tip(${pythonArgs.join(', ')})`
6967

7068
const commands: CreateCommand[] = [
7169
{

0 commit comments

Comments
 (0)