Skip to content
Open
67 changes: 58 additions & 9 deletions shared-data/command/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export type ModuleRunTimeCommand =
| AbsorbanceReaderCloseLidRunTimeCommand
| AbsorbanceReaderInitializeRunTimeCommand
| AbsorbanceReaderReadRunTimeCommand
| FlexStackerSetStoredLabwareRunTimeCommand
| FlexStackerEmptyRunTimeCommand
| FlexStackerFillItemsRunTimeCommand
| FlexStackerFillRunTimeCommand
| FlexStackerRetrieveRunTimeCommand
| FlexStackerSetStoredLabwareItemsRunTimeCommand
| FlexStackerSetStoredLabwareRunTimeCommand
| FlexStackerStoreRunTimeCommand
| FlexStackerFillRunTimeCommand
| FlexStackerEmptyRunTimeCommand
| IdentifyModuleRunTimeCommand

export type ModuleCreateCommand =
Expand Down Expand Up @@ -73,14 +75,16 @@ export type ModuleCreateCommand =
| AbsorbanceReaderCloseLidCreateCommand
| AbsorbanceReaderInitializeCreateCommand
| AbsorbanceReaderReadCreateCommand
| FlexStackerSetStoredLabwareCreateCommand
| FlexStackerRetrieveCreateCommand
| FlexStackerStoreCreateCommand
| FlexStackerFillCreateCommand
| FlexStackerCloseLatch
| FlexStackerEmptyCreateCommand
| FlexStackerPrepareShuttleCreateCommand
| FlexStackerFillCreateCommand
| FlexStackerFillItemsCreateCommand
| FlexStackerOpenLatch
| FlexStackerCloseLatch
| FlexStackerPrepareShuttleCreateCommand
| FlexStackerRetrieveCreateCommand
| FlexStackerSetStoredLabwareCreateCommand
| FlexStackerSetStoredLabwareItemsCreateCommand
| FlexStackerStoreCreateCommand
| IdentifyModuleCreateCommand

export interface MagneticModuleEngageMagnetCreateCommand
Expand Down Expand Up @@ -487,6 +491,29 @@ export interface FlexStackerSetStoredLabwareRunTimeCommand
} & StackerStoredLabwareLocationSequences
}

export interface FlexStackerSetStoredLabwareItemsParams {
moduleId: string
labware: string[]
stackingOffsetZ?: number
}
export interface FlexStackerSetStoredLabwareItemsCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/setStoredLabwareItems'
params: FlexStackerSetStoredLabwareItemsParams
}

export interface FlexStackerSetStoredLabwareItemsRunTimeCommand
extends FlexStackerSetStoredLabwareItemsCreateCommand,
CommonCommandRunTimeInfo {
result?: {
primaryLabwareDefinition: LabwareDefinition
lidLabwareDefinition?: LabwareDefinition | null
adapterLabwareDefinition?: LabwareDefinition | null
count: number
storedLabware: FlexStackerStoredLabwareGroup[]
} & StackerStoredLabwareLocationSequences
}

export interface FlexStackerRetrieveCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/retrieve'
Expand Down Expand Up @@ -516,6 +543,28 @@ export interface FlexStackerFillCreateCommand extends CommonCommandCreateInfo {
params: FlexStackerFillParams
}

export interface FlexStackerFillItemsParams {
moduleId: string
labware: string[]
}

export interface FlexStackerFillItemsCreateCommand
extends CommonCommandCreateInfo {
commandType: 'flexStacker/fillItems'
params: FlexStackerFillItemsParams
}

export interface FlexStackerFillItemsRunTimeCommand
extends FlexStackerFillItemsCreateCommand,
CommonCommandRunTimeInfo {
result?: {
count: number
storedLabware?: FlexStackerStoredLabwareGroup[] | null
addedLabware?: FlexStackerStoredLabwareGroup[] | null
} & StackerStoredLabwareLocationSequences &
StackerStoredLabwareDefinitionURIs
}

export interface FlexStackerEmptyParams {
moduleId: string
strategy: 'manualWithPause' | 'logical'
Expand Down
79 changes: 0 additions & 79 deletions step-generation/src/__tests__/flexStackerFill.test.ts

This file was deleted.

129 changes: 129 additions & 0 deletions step-generation/src/__tests__/flexStackerFillItems.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'

import {

Check failure on line 3 in step-generation/src/__tests__/flexStackerFillItems.test.ts

View workflow job for this annotation

GitHub Actions / js checks

Import "LabwareDefinition2" is only used as types

Check failure on line 3 in step-generation/src/__tests__/flexStackerFillItems.test.ts

View workflow job for this annotation

GitHub Actions / js checks

Import "LabwareDefinition2" is only used as types
fixture96Plate,
FLEX_STACKER_MODULE_TYPE,
FLEX_STACKER_MODULE_V1,
LabwareDefinition2,
} from '@opentrons/shared-data'

import { flexStackerFillItems } from '../commandCreators/atomic/flexStackerFillItems'
import { getInitialRobotStateStandard, makeContext } from '../fixtures'

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

const moduleId = 'flexStackerId'
const labwareId = 'labwareId'
const labwareId2 = 'labwareId2'
const labwareId3 = 'labwareId3'
const labwareId4 = 'labwareId4'
const labwareId5 = 'labwareId5'
vi.mock('../robotStateSelectors')

describe('flexStackerFillItems', () => {
let invariantContext: InvariantContext
let robotState: RobotState
beforeEach(() => {
invariantContext = makeContext()
robotState = getInitialRobotStateStandard(invariantContext)
invariantContext.moduleEntities[moduleId] = {
id: moduleId,
type: FLEX_STACKER_MODULE_TYPE,
model: FLEX_STACKER_MODULE_V1,
pythonName: 'mock_flex_stacker_1',
}
invariantContext.labwareEntities = {
[labwareId]: {
id: labwareId,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_1',
},
[labwareId2]: {
id: labwareId2,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_2',
},
[labwareId3]: {
id: labwareId3,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_3',
},
[labwareId4]: {
id: labwareId4,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_4',
},
[labwareId5]: {
id: labwareId5,
def: fixture96Plate as LabwareDefinition2,
labwareDefURI: 'mockURI',
pythonName: 'mock_labware_5',
},
}
})
it('creates flex stacker fill command with 1 labware', () => {
const result = flexStackerFillItems(
{
moduleId,
labware: [labwareId],
},
invariantContext,
robotState
)
expect(result).toEqual({
commands: [
{
commandType: 'flexStacker/fillItems',
key: expect.any(String),
params: {
moduleId,
labware: [labwareId],
},
},
],
python: `
mock_flex_stacker_1.fill_items(
labware=[mock_labware_1],
)`.trimStart(),
})
})
it('creates flex stacker fill command with 5 labware', () => {
const result = flexStackerFillItems(
{
moduleId,
labware: [labwareId, labwareId2, labwareId3, labwareId4, labwareId5],
},
invariantContext,
robotState
)
expect(result).toEqual({
commands: [
{
commandType: 'flexStacker/fillItems',
key: expect.any(String),
params: {
moduleId,
labware: [
labwareId,
labwareId2,
labwareId3,
labwareId4,
labwareId5,
],
},
},
],
python: `
mock_flex_stacker_1.fill_items(
labware=[
mock_labware_1, mock_labware_2, mock_labware_3, mock_labware_4,
mock_labware_5
],
)`.trimStart(),
})
})
})
2 changes: 1 addition & 1 deletion step-generation/src/__tests__/flexStackerRetrieve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('flexStackerRetrieve', () => {
},
},
],
python: 'wellPlate_1 = mock_flex_stacker_1.retrieve()',
python: 'mock_flex_stacker_1.retrieve()',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

})
})
})
14 changes: 5 additions & 9 deletions step-generation/src/__tests__/pythonFileUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
WATER_LIQUID_CLASS_NAME,
} from '@opentrons/shared-data'

import { HOPPER_STACKER_LOCATION } from '../constants'
import {
formatChangeTipArg,
formatPyStr,
Expand Down Expand Up @@ -440,7 +441,6 @@ well_plate_3 = protocol.load_labware_from_definition(
},
}
const mockLabwareEntitiesWithFlexStackerLabware = {
...mockLabwareEntities,
[flexStackerLabwareId]: {
id: flexStackerLabwareId,
labwareDefURI: 'opentrons/fixture_96_plate/1',
Expand All @@ -450,10 +450,8 @@ well_plate_3 = protocol.load_labware_from_definition(
}

const mockLabwareRobotStateWithFlexStackerLabware = {
...labwareRobotState,
[flexStackerLabwareId]: {
...labwareRobotState[labwareId6],
stack: [flexStackerLabwareId, moduleId4, 'A4'],
stack: [flexStackerLabwareId, HOPPER_STACKER_LOCATION, moduleId4, 'A4'],
},
}

Expand All @@ -465,11 +463,9 @@ well_plate_3 = protocol.load_labware_from_definition(

expect(setStoredLabware).toBe(
`# Set Stored Labware:
flex_stacker_1 = protocol.set_stored_labware(
loadName="fixture_96_plate",
namespace="opentrons",
version=1,
count=1)`.trimStart()
flex_stacker_1 = protocol.set_stored_labware_list(
labware=[well_plate_4],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity: Is the PD UI not going to ask the user for a string so that the user has something to look at when the ODD prompts them to fill the hopper? (The message arg to fill_items().)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooh this is an option, yes. i'll add the message arg

)`.trimStart()
)
})
})
Expand Down
35 changes: 0 additions & 35 deletions step-generation/src/commandCreators/atomic/flexStackerFill.ts

This file was deleted.

Loading
Loading