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(opentrons-ai-client): filter out retired and old labware #16775

Merged
merged 2 commits into from
Nov 12, 2024
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
Expand Up @@ -10,11 +10,11 @@ const TestFormProviderComponent = () => {
defaultValues: {
labwares: [
{
labwareURI: 'opentrons/eppendorf_96_tiprack_1000ul_eptips/1',
labwareURI: 'opentrons/opentrons_flex_96_tiprack_1000ul/1',
count: 1,
},
{
labwareURI: 'opentrons/eppendorf_96_tiprack_10ul_eptips/1',
labwareURI: 'opentrons/opentrons_flex_96_tiprack_50ul/1',
count: 1,
},
],
Expand All @@ -39,10 +39,10 @@ describe('ControlledLabwareListItems', () => {
render()

expect(
screen.getByText('(Retired) Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.getByText('Opentrons Flex 96 Tip Rack 1000 µL')
).toBeInTheDocument()
expect(
screen.getByText('(Retired) Eppendorf epT.I.P.S. 96 Tip Rack 10 µL')
screen.getByText('Opentrons Flex 96 Tip Rack 50 µL')
).toBeInTheDocument()
})

Expand All @@ -64,15 +64,15 @@ describe('ControlledLabwareListItems', () => {
render()

expect(
screen.getByText('(Retired) Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.getByText('Opentrons Flex 96 Tip Rack 1000 µL')
).toBeInTheDocument()

const removeButton = screen.getAllByText('Remove')[0]
fireEvent.click(removeButton)

await waitFor(() => {
expect(
screen.queryByText('(Retired) Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.queryByText('Opentrons Flex 96 Tip Rack 1000 µL')
).not.toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import {
import type { DropdownBorder } from '@opentrons/components'
import { Controller, useFormContext } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import {
getAllDefinitions,
getLabwareDisplayName,
} from '@opentrons/shared-data'
import { getLabwareDisplayName } from '@opentrons/shared-data'
import { LabwareDiagram } from '../../molecules/LabwareDiagram'
import type { DisplayLabware } from '../../organisms/LabwareLiquidsSection'
import { LABWARES_FIELD_NAME } from '../../organisms/LabwareLiquidsSection'
import { getAllDefinitions } from '../../resources/utils'

export function ControlledLabwareListItems(): JSX.Element | null {
const { t } = useTranslation('create_protocol')
Expand Down
2 changes: 1 addition & 1 deletion opentrons-ai-client/src/molecules/InputPrompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
tokenAtom,
} from '../../resources/atoms'
import { useApiCall } from '../../resources/hooks'
import { calcTextAreaHeight } from '../../resources/utils/utils'
import { calcTextAreaHeight } from '../../resources/utils'
import {
STAGING_END_POINT,
PROD_END_POINT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import type { DropdownBorder } from '@opentrons/components'
import {
ABSORBANCE_READER_TYPE,
getAllDefinitions,
getModuleDisplayName,
HEATERSHAKER_MODULE_TYPE,
MAGNETIC_BLOCK_TYPE,
Expand All @@ -23,6 +22,7 @@ import { Controller, useFormContext } from 'react-hook-form'
import { ModuleDiagram } from '../ModelDiagram'
import { MODULES_FIELD_NAME } from '../../organisms/ModulesSection'
import type { DisplayModules } from '../../organisms/ModulesSection'
import { getAllDefinitions } from '../../resources/utils'
import { useTranslation } from 'react-i18next'
import { useMemo } from 'react'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('LabwareLiquidsSection', () => {

fireEvent.click(screen.getByText('Tip rack'))
fireEvent.click(
await screen.findByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
await screen.findByText('Opentrons Flex 96 Tip Rack 1000 µL')
)
fireEvent.click(screen.getByText('Save'))

Expand All @@ -61,7 +61,7 @@ describe('LabwareLiquidsSection', () => {

// fireEvent.click(screen.getByText('Tip rack'))
// fireEvent.click(
// await screen.findByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
// await screen.findByText('Opentrons Flex 96 Tip Rack 1000 µL')
// )
// fireEvent.click(screen.getByText('Save'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ describe('LabwareModal', () => {
render()

expect(
screen.queryByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.queryByText('Opentrons Flex 96 Tip Rack 1000 µL')
).not.toBeInTheDocument()

const categoryButton = screen.getByText('Tip rack')
categoryButton.click()

await waitFor(() => {
expect(
screen.getByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.getByText('Opentrons Flex 96 Tip Rack 1000 µL')
).toBeInTheDocument()
})
})
Expand All @@ -94,7 +94,7 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
expect(labware).not.toBeChecked()

Expand All @@ -111,10 +111,10 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware1 = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
const labware2 = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 10 µL'
'Opentrons Flex 96 Tip Rack 50 µL'
)

labware1.click()
Expand All @@ -132,7 +132,7 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
labware.click()
labware.click()
Expand All @@ -152,7 +152,7 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware1 = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
labware1.click()

Expand Down Expand Up @@ -180,7 +180,7 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware1 = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
labware1.click()

Expand All @@ -191,7 +191,7 @@ describe('LabwareModal', () => {

await waitFor(() => {
expect(
screen.getByText('opentrons/eppendorf_96_tiprack_1000ul_eptips/1')
screen.getByText('opentrons/opentrons_flex_96_tiprack_1000ul/1')
).toBeInTheDocument()
})
})
Expand All @@ -208,7 +208,7 @@ describe('LabwareModal', () => {
categoryButton.click()

const labware1 = await screen.findByLabelText(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
labware1.click()

Expand All @@ -219,7 +219,7 @@ describe('LabwareModal', () => {

await waitFor(() => {
expect(
screen.getByText('opentrons/eppendorf_96_tiprack_1000ul_eptips/1')
screen.getByText('opentrons/opentrons_flex_96_tiprack_1000ul/1')
).toBeInTheDocument()
})

Expand All @@ -230,7 +230,7 @@ describe('LabwareModal', () => {

await waitFor(() => {
expect(
screen.getByText('opentrons/eppendorf_96_tiprack_1000ul_eptips/1')
screen.getByText('opentrons/opentrons_flex_96_tiprack_1000ul/1')
).toBeInTheDocument()
})
})
Expand All @@ -241,20 +241,20 @@ describe('LabwareModal', () => {

const searchInput = screen.getByPlaceholderText('Search for labware...')
fireEvent.change(searchInput, {
target: { value: 'Eppendorf epT.I.P.S. 96 Tip Rack 10 µL' },
target: { value: 'Opentrons Flex 96 Tip Rack 50 µL' },
})

const categoryButton = screen.getByText('Tip rack')
categoryButton.click()

await waitFor(() => {
expect(
screen.getByText('Eppendorf epT.I.P.S. 96 Tip Rack 10 µL')
screen.getByText('Opentrons Flex 96 Tip Rack 50 µL')
).toBeInTheDocument()
})

expect(
screen.queryByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
screen.queryByText('Opentrons Flex 96 Tip Rack 1000 µL')
).not.toBeInTheDocument()
})
})
13 changes: 7 additions & 6 deletions opentrons-ai-client/src/organisms/LabwareModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ import {
} from '@opentrons/components'
import { useFormContext } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import type {
LabwareDefByDefURI,
LabwareDefinition2,
} from '@opentrons/shared-data'
import { getLabwareDefURI, getAllDefinitions } from '@opentrons/shared-data'
import { getLabwareDefURI } from '@opentrons/shared-data'
import React, { useEffect, useMemo, useState } from 'react'
import { createPortal } from 'react-dom'
import { reduce } from 'lodash'
import { ListButtonCheckbox } from '../../atoms/ListButtonCheckbox/ListButtonCheckbox'
import type { DisplayLabware } from '../LabwareLiquidsSection'
import { LABWARES_FIELD_NAME } from '../LabwareLiquidsSection'
import { getAllDefinitions } from '../../resources/utils'
import type { DisplayLabware } from '../LabwareLiquidsSection'
import type {
LabwareDefByDefURI,
LabwareDefinition2,
} from '@opentrons/shared-data'

const ORDERED_CATEGORIES: string[] = [
'tipRack',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('CreateProtocol', () => {

expect(previewItems).toHaveLength(9)
expect(previewItems[7]).toHaveTextContent(
'Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL'
'Opentrons Flex 96 Tip Rack 1000 µL'
)
expect(previewItems[8]).toHaveTextContent('Test liquid')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { calcTextAreaHeight } from '../utils'
import { calcTextAreaHeight } from '../index'

describe('calcTextAreaHeight', () => {
it('should return the correct number of lines', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ export async function fillLabwareLiquidsSectionAndClickConfirm(): Promise<void>
fireEvent.click(addButton)

fireEvent.click(screen.getByText('Tip rack'))
fireEvent.click(
await screen.findByText('Eppendorf epT.I.P.S. 96 Tip Rack 1000 µL')
)
fireEvent.click(await screen.findByText('Opentrons Flex 96 Tip Rack 1000 µL'))
fireEvent.click(screen.getByText('Save'))

fireEvent.change(screen.getByRole('textbox'), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
getAllDefinitions,
getLabwareDisplayName,
getPipetteSpecsV2,
} from '@opentrons/shared-data'
Expand All @@ -14,6 +13,7 @@ import {
} from '../../organisms/InstrumentsSection'
import type { UseFormWatch } from 'react-hook-form'
import type { CreateProtocolFormData } from '../../pages/CreateProtocol'
import { getAllDefinitions } from './labware'

export function generatePromptPreviewApplicationItems(
watch: UseFormWatch<CreateProtocolFormData>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ export const isLocalhost = (): boolean => {
host === 'localhost' || host === '127.0.0.1' || host.startsWith('192.168.')
)
}

export * from './labware'
17 changes: 17 additions & 0 deletions opentrons-ai-client/src/resources/utils/labware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
LABWAREV2_DO_NOT_LIST,
RETIRED_LABWARE,
getAllDefinitions as _getAllDefinitions,
} from '@opentrons/shared-data'
import type { LabwareDefByDefURI } from '@opentrons/shared-data'

let _definitions: LabwareDefByDefURI | null = null
export function getAllDefinitions(): LabwareDefByDefURI {
Copy link
Member Author

Choose a reason for hiding this comment

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

added our own labware getter in the ai project so we can cache all labware (which includes our filter).

if we only did this in the labware modal, the issue is that the filter would never get applied since the _definitions private object only gets instantiated once

if (_definitions == null) {
_definitions = _getAllDefinitions([
...RETIRED_LABWARE,
...LABWAREV2_DO_NOT_LIST,
])
}
return _definitions
}
2 changes: 1 addition & 1 deletion shared-data/js/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const constructLabwareDefURI = (
// Load names of "retired" labware
// TODO(mc, 2019-12-3): how should this correspond to LABWAREV2_DO_NOT_LIST?
// see shared-data/js/getLabware.js
const RETIRED_LABWARE = [
export const RETIRED_LABWARE = [
'geb_96_tiprack_10ul',
'geb_96_tiprack_1000ul',
'opentrons_1_trash_850ml_fixed',
Expand Down
Loading