Skip to content

Commit 328df5f

Browse files
authored
feat(step-generation): py commands for move_to well (#17846)
1 parent d72ee2c commit 328df5f

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

shared-data/command/types/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export * from './pipetting'
3030
export * from './setup'
3131
export * from './timing'
3232
export * from './unsafe'
33-
33+
export * from './support'
3434
// NOTE: these key/value pairs will only be present on commands at analysis/run time
3535
// they pertain only to the actual execution status of a command on hardware, as opposed to
3636
// the command's identity and parameters which can be known prior to runtime

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

+14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
SOURCE_LABWARE,
2424
} from '../fixtures'
2525
import type { InvariantContext, RobotState } from '../types'
26+
import type { WellOrigin } from '@opentrons/shared-data'
2627

2728
vi.mock('../utils/absorbanceReaderCollision')
2829
vi.mock('../utils/thermocyclerPipetteCollision')
@@ -46,6 +47,10 @@ describe('moveToWell', () => {
4647
pipetteId: DEFAULT_PIPETTE,
4748
labwareId: SOURCE_LABWARE,
4849
wellName: 'A1',
50+
wellLocation: {
51+
origin: 'bottom' as WellOrigin,
52+
offset: { z: 1 },
53+
},
4954
}
5055
const result = moveToWell(params, invariantContext, robotStateWithTip)
5156
expect(getSuccessResult(result).commands).toEqual([
@@ -56,9 +61,18 @@ describe('moveToWell', () => {
5661
pipetteId: DEFAULT_PIPETTE,
5762
labwareId: SOURCE_LABWARE,
5863
wellName: 'A1',
64+
wellLocation: {
65+
origin: 'bottom' as any,
66+
offset: {
67+
z: 1,
68+
},
69+
},
5970
},
6071
},
6172
])
73+
expect(getSuccessResult(result).python).toBe(
74+
'mockPythonName.move_to(mockPythonName["A1"].bottom(z=1))'
75+
)
6276
})
6377
it('should apply the optional params to the command', () => {
6478
const params = {

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

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
getIsHeaterShakerEastWestMultiChannelPipette,
1313
getIsHeaterShakerNorthSouthOfNonTiprackWithMultiChannelPipette,
1414
uuid,
15+
formatPyStr,
16+
formatPyWellLocation,
1517
} from '../../utils'
1618
import { COLUMN_4_SLOTS } from '../../constants'
1719
import type { CreateCommand, MoveToWellParams } from '@opentrons/shared-data'
@@ -34,9 +36,8 @@ export const moveToWell: CommandCreator<MoveToWellParams> = (
3436
const actionName = 'moveToWell'
3537
const errors: CommandCreatorError[] = []
3638
const labwareState = prevRobotState.labware
37-
// TODO(2020-07-30, IL): the below is duplicated or at least similar
38-
// across aspirate/dispense/blowout, we can probably DRY it up
39-
const pipetteSpec = invariantContext.pipetteEntities[pipetteId]?.spec
39+
const { pipetteEntities, labwareEntities } = invariantContext
40+
const pipetteSpec = pipetteEntities[pipetteId]?.spec
4041
const isFlexPipette =
4142
(pipetteSpec?.displayCategory === 'FLEX' || pipetteSpec?.channels === 96) ??
4243
false
@@ -160,7 +161,7 @@ export const moveToWell: CommandCreator<MoveToWellParams> = (
160161
prevRobotState.modules,
161162
slotName,
162163
pipetteSpec,
163-
invariantContext.labwareEntities[labwareId]
164+
labwareEntities[labwareId]
164165
)
165166
) {
166167
errors.push(
@@ -174,6 +175,9 @@ export const moveToWell: CommandCreator<MoveToWellParams> = (
174175
}
175176
}
176177

178+
const pipettePythonName = pipetteEntities[pipetteId].pythonName
179+
const labwarePythonName = labwareEntities[labwareId].pythonName
180+
177181
const commands: CreateCommand[] = [
178182
{
179183
commandType: 'moveToWell',
@@ -188,7 +192,11 @@ export const moveToWell: CommandCreator<MoveToWellParams> = (
188192
},
189193
},
190194
]
195+
// NOTE: forceDirect and minimumZHeight were never wired up in the form or stepArgs
191196
return {
192197
commands,
198+
python: `${pipettePythonName}.move_to(${labwarePythonName}[${formatPyStr(
199+
wellName
200+
)}]${formatPyWellLocation(wellLocation)})`,
193201
}
194202
}

0 commit comments

Comments
 (0)