Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(step-generation): py command for dropping tip in waste chute #17831

Merged
merged 3 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
dropTipInPlace,
moveToAddressableArea,
getWasteChuteAddressableAreaNamePip,
dropTipInTrash,
dropTipInWasteChute,
curryCommandCreator,
dropTip,
reduceCommandCreators,
commandCreatorsTimeline,
getPipetteIdFromCCArgs,
ZERO_OFFSET,
} from '@opentrons/step-generation'
import { commandCreatorFromStepArgs } from '../file-data/helpers'
import type { StepArgsAndErrorsById } from '../steplist/types'
Expand Down Expand Up @@ -75,11 +72,6 @@
const isWasteChute = dropTipEntity?.name === 'wasteChute'
const isTrashBin = dropTipEntity?.name === 'trashBin'

const pipetteSpec = invariantContext.pipetteEntities[pipetteId]?.spec
const addressableAreaNameWasteChute = getWasteChuteAddressableAreaNamePip(
pipetteSpec.channels
)

let dropTipCommands = [
curryCommandCreator(dropTip, {
pipette: pipetteId,
Expand All @@ -88,13 +80,9 @@
]
if (isWasteChute) {
dropTipCommands = [
curryCommandCreator(moveToAddressableArea, {
pipetteId,
addressableAreaName: addressableAreaNameWasteChute,
offset: ZERO_OFFSET,
}),
curryCommandCreator(dropTipInPlace, {
curryCommandCreator(dropTipInWasteChute, {

Check warning on line 83 in protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts#L83

Added line #L83 was not covered by tests
pipetteId,
wasteChuteId: dropTipEntity.id,

Check warning on line 85 in protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/timelineMiddleware/generateRobotStateTimeline.ts#L85

Added line #L85 was not covered by tests
}),
]
}
Expand Down
29 changes: 12 additions & 17 deletions step-generation/src/__tests__/dropTipInWasteChute.test.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
import { describe, it, expect, vi } from 'vitest'
import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data'
import { getSuccessResult, makeContext } from '../fixtures'
import { DEFAULT_PIPETTE, getSuccessResult, makeContext } from '../fixtures'
import { dropTipInWasteChute } from '../commandCreators'

import type { InvariantContext, PipetteEntities, RobotState } from '../types'
import type { InvariantContext, RobotState } from '../types'

vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')

const mockWasteChuteId = 'mockWasteChuteId'
const mockId = 'mockId'

const mockPipEntities: PipetteEntities = {
[mockId]: {
name: 'p50_single_flex',
id: mockId,
spec: { channels: 1 },
},
} as any

const invariantContext: InvariantContext = {
...makeContext(),
pipetteEntities: mockPipEntities,
additionalEquipmentEntities: {
[mockWasteChuteId]: {
name: 'wasteChute' as const,
location: WASTE_CHUTE_CUTOUT,
id: mockWasteChuteId,
pythonName: 'mock_waste_chute_1',
},
},
}
const prevRobotState: RobotState = {
tipState: { pipettes: { [mockId]: true } } as any,
tipState: { pipettes: { [DEFAULT_PIPETTE]: true } } as any,
} as any

describe('dropTipInWasteChute', () => {
it('returns correct commands for drop tip', () => {
it('returns correct commands for drop tip in waste chute', () => {
const args = {
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
wasteChuteId: mockWasteChuteId,
}
const result = dropTipInWasteChute(args, invariantContext, prevRobotState)
expect(getSuccessResult(result).commands).toEqual([
{
commandType: 'moveToAddressableArea',
key: expect.any(String),
params: {
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
addressableAreaName: '1ChannelWasteChute',
offset: { x: 0, y: 0, z: 0 },
},
Expand All @@ -53,9 +45,12 @@ describe('dropTipInWasteChute', () => {
commandType: 'dropTipInPlace',
key: expect.any(String),
params: {
pipetteId: mockId,
pipetteId: DEFAULT_PIPETTE,
},
},
])
expect(getSuccessResult(result).python).toBe(
'mockPythonName.drop_tip(mock_waste_chute_1)'
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ export const consolidate: CommandCreator<ConsolidateArgs> = (
dropTipCommand = [
curryCommandCreator(dropTipInWasteChute, {
pipetteId: args.pipette,
wasteChuteId: dropTipEntity.id,
}),
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@
dropTipCommand = [
curryCommandCreator(dropTipInWasteChute, {
pipetteId: args.pipette,
wasteChuteId: dropTipEntity.id,

Check warning on line 389 in step-generation/src/commandCreators/compound/distribute.ts

View check run for this annotation

Codecov / codecov/patch

step-generation/src/commandCreators/compound/distribute.ts#L389

Added line #L389 was not covered by tests
}),
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
curryCommandCreator,
curryWithoutPython,
getWasteChuteAddressableAreaNamePip,
reduceCommandCreators,
} from '../../utils'
Expand All @@ -9,6 +9,7 @@ import type { CommandCreator, CurriedCommandCreator } from '../../types'

interface DropTipInWasteChuteArgs {
pipetteId: string
wasteChuteId: string
}

export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
Expand All @@ -17,9 +18,9 @@ export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
prevRobotState
) => {
const offset = ZERO_OFFSET
const { pipetteId } = args
const pipetteChannels =
invariantContext.pipetteEntities[pipetteId].spec.channels
const { pipetteId, wasteChuteId } = args
const { pipetteEntities, additionalEquipmentEntities } = invariantContext
const pipetteChannels = pipetteEntities[pipetteId].spec.channels
const addressableAreaName = getWasteChuteAddressableAreaNamePip(
pipetteChannels
)
Expand All @@ -30,15 +31,24 @@ export const dropTipInWasteChute: CommandCreator<DropTipInWasteChuteArgs> = (
if (!prevRobotState.tipState.pipettes[pipetteId]) {
commandCreators = []
} else {
const pipettePythonName = pipetteEntities[pipetteId].pythonName
const wasteChutePythonName =
additionalEquipmentEntities[wasteChuteId].pythonName
const pythonCommandCreator: CurriedCommandCreator = () => ({
commands: [],
python: `${pipettePythonName}.drop_tip(${wasteChutePythonName})`,
})

commandCreators = [
curryCommandCreator(moveToAddressableArea, {
curryWithoutPython(moveToAddressableArea, {
pipetteId,
addressableAreaName,
offset,
}),
curryCommandCreator(dropTipInPlace, {
curryWithoutPython(dropTipInPlace, {
pipetteId,
}),
pythonCommandCreator,
]
}
return reduceCommandCreators(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const replaceTip: CommandCreator<ReplaceTipArgs> = (
commandCreators = [
curryCommandCreator(dropTipInWasteChute, {
pipetteId: args.pipette,
wasteChuteId: dropTipEntity.id,
}),
...configureNozzleLayoutCommand,
curryCommandCreator(pickUpTip, {
Expand Down
1 change: 1 addition & 0 deletions step-generation/src/commandCreators/compound/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ export const transfer: CommandCreator<TransferArgs> = (
dropTipCommand = [
curryCommandCreator(dropTipInWasteChute, {
pipetteId: args.pipette,
wasteChuteId: dropTipEntity.id,
}),
]
}
Expand Down
1 change: 1 addition & 0 deletions step-generation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
dropTip,
dropTipInPlace,
dropTipInTrash,
dropTipInWasteChute,
engageMagnet,
heaterShaker,
mix,
Expand Down
Loading