Skip to content

Commit

Permalink
migrate a bunch of components to new pipette spec util
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader committed Mar 18, 2024
1 parent bfbfeb2 commit f8c7a40
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 78 deletions.
4 changes: 2 additions & 2 deletions components/src/instrument/InstrumentDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import singleFlexSrc from './single-channel-flex.png'
import eightChannelFlexSrc from './eight-channel-flex.png'
import ninetySixSrc from './ninety-six-channel-gen1.png'

import type { PipetteNameSpecs } from '@opentrons/shared-data'
import type { PipetteV2Specs } from '@opentrons/shared-data'
import type { Mount } from '../robot-types'
import type { StyleProps } from '..'

export interface InstrumentDiagramProps extends StyleProps {
mount: Mount
pipetteSpecs?: Pick<PipetteNameSpecs, 'displayCategory' | 'channels'> | null
pipetteSpecs?: Pick<PipetteV2Specs, 'displayCategory' | 'channels'> | null
className?: string
imageStyle?: FlattenSimpleInterpolation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function FlowRateField(props: OP): JSX.Element {
const pipette = pipetteId != null ? pipetteEntities[pipetteId] : null
const pipetteDisplayName = pipette ? pipette.spec.displayName : 'pipette'
const innerKey = `${name}:${String(value || 0)}`

let defaultFlowRate
if (pipette) {
if (flowRateType === 'aspirate') {
Expand All @@ -36,7 +37,9 @@ export function FlowRateField(props: OP): JSX.Element {
key={innerKey}
defaultFlowRate={defaultFlowRate}
minFlowRate={0}
maxFlowRate={pipette ? pipette.spec.maxVolume : Infinity}
maxFlowRate={
pipette ? pipette.spec.liquids['default'].maxVolume : Infinity

Check failure on line 41 in protocol-designer/src/components/StepEditForm/fields/FlowRateField/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

["default"] is better written in dot notation
}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {
sortWells,
LabwareDefinition2,
PipetteNameSpecs,
PipetteV2Specs,
} from '@opentrons/shared-data'

import { arrayToWellGroup } from '../../../../utils'
Expand Down Expand Up @@ -54,7 +54,7 @@ interface WellSelectionModalComponentProps {
updateHighlightedWells: (wellGroup: WellGroup) => unknown
wellContents: ContentsByWell
labwareDef?: LabwareDefinition2 | null
pipetteSpec?: PipetteNameSpecs | null
pipetteSpec?: PipetteV2Specs | null
}

const WellSelectionModalComponent = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
HEATERSHAKER_MODULE_TYPE,
MAGNETIC_MODULE_TYPE,
TEMPERATURE_MODULE_TYPE,
getPipetteNameSpecs,
getPipetteSpecsV2,
PipetteName,
OT2_ROBOT_TYPE,
THERMOCYCLER_MODULE_V2,
Expand Down Expand Up @@ -105,8 +105,8 @@ export function ModulesAndOtherTile(props: WizardTileProps): JSX.Element {
const showHeaterShakerPipetteCollisions =
hasHeaterShakerSelected &&
[
getPipetteNameSpecs(left.pipetteName as PipetteName),
getPipetteNameSpecs(right.pipetteName as PipetteName),
getPipetteSpecsV2(left.pipetteName as PipetteName),
getPipetteSpecsV2(right.pipetteName as PipetteName),
].some(pipetteSpecs => pipetteSpecs && pipetteSpecs.channels !== 1)

const crashablePipetteSelected = getIsCrashablePipetteSelected(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
Btn,
JUSTIFY_END,
} from '@opentrons/components'
import { getPipetteNameSpecs } from '@opentrons/shared-data'
import { getPipetteSpecsV2 } from '@opentrons/shared-data'
import { getLabwareDefsByURI } from '../../../labware-defs/selectors'
import { createCustomTiprackDef } from '../../../labware-defs/actions'
import { getAllowAllTipracks } from '../../../feature-flags/selectors'
Expand Down Expand Up @@ -72,8 +72,7 @@ export function PipetteTipsTile(props: PipetteTipsTileProps): JSX.Element {
const tileHeader = t('choose_tips_for_pipette', {
pipetteName:
firstPipetteName != null
? getPipetteNameSpecs(firstPipetteName as PipetteName)?.displayName ??
''
? getPipetteSpecsV2(firstPipetteName as PipetteName)?.displayName ?? ''
: '',
})

Expand Down Expand Up @@ -160,8 +159,9 @@ function PipetteTipsField(props: PipetteTipsFieldProps): JSX.Element | null {
const selectedPipetteName = pipettesByMount[mount].pipetteName
const selectedPipetteDefaultTipracks =
selectedPipetteName != null
? getPipetteNameSpecs(selectedPipetteName as PipetteName)
?.defaultTipracks ?? []
? getPipetteSpecsV2(selectedPipetteName as PipetteName)?.liquids[
'default'

Check failure on line 163 in protocol-designer/src/components/modals/CreateFileWizard/PipetteTipsTile.tsx

View workflow job for this annotation

GitHub Actions / js checks

["default"] is better written in dot notation
].defaultTipracks ?? []
: []
const tiprackOptions = getTiprackOptions({
allLabware: allLabware,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
OT2_ROBOT_TYPE,
OT3_PIPETTES,
getAllPipetteNames,
getPipetteNameSpecs,
LEFT,
RIGHT,
getPipetteSpecsV2,
} from '@opentrons/shared-data'

import { GoBack } from './GoBack'
Expand Down Expand Up @@ -141,7 +141,7 @@ function PipetteField(props: OT2FieldProps): JSX.Element {
)
.map(name => ({
value: name,
name: getPipetteNameSpecs(name)?.displayName ?? '',
name: getPipetteSpecsV2(name)?.displayName ?? '',
}))
const noneOption = allowNoPipette ? [{ name: 'None', value: '' }] : []
return display96Channel
Expand Down Expand Up @@ -180,7 +180,7 @@ function PipetteField(props: OT2FieldProps): JSX.Element {
imageStyle={css`
max-height: 3rem;
`}
pipetteSpecs={getPipetteNameSpecs(o.value as PipetteName)}
pipetteSpecs={getPipetteSpecsV2(o.value as PipetteName)}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { css } from 'styled-components'
import cx from 'classnames'
import {
FLEX_ROBOT_TYPE,
getPipetteNameSpecs,
getPipetteSpecsV2,
PipetteName,
} from '@opentrons/shared-data'
import { InstrumentDiagram } from '@opentrons/components'
Expand Down Expand Up @@ -32,11 +32,10 @@ export function PipetteDiagram(props: Props): JSX.Element {
function PipetteGroup(props: Props): JSX.Element {
const { leftPipette, rightPipette } = props
const robotType = useSelector(getRobotType)
const leftSpecs =
leftPipette && getPipetteNameSpecs(leftPipette as PipetteName)
const leftSpecs = leftPipette && getPipetteSpecsV2(leftPipette as PipetteName)
const has96Channel = leftPipette === 'p1000_96'
const rightSpecs =
rightPipette && getPipetteNameSpecs(rightPipette as PipetteName)
rightPipette && getPipetteSpecsV2(rightPipette as PipetteName)
return (
<>
{leftPipette && leftSpecs ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
HEATERSHAKER_MODULE_TYPE,
ModuleType,
ModuleModel,
getPipetteNameSpecs,
PipetteName,
MAGNETIC_BLOCK_V1,
MAGNETIC_BLOCK_TYPE,
OT2_ROBOT_TYPE,
getPipetteSpecsV2,
} from '@opentrons/shared-data'
import { StepChangesConfirmModal } from '../EditPipettesModal/StepChangesConfirmModal'
import { PipetteFields } from './PipetteFields'
Expand Down Expand Up @@ -455,8 +455,8 @@ export const FilePipettesModal = (props: Props): JSX.Element => {
const showHeaterShakerPipetteCollisions =
hasHeaterShakerSelected &&
[
getPipetteNameSpecs(left.pipetteName as PipetteName),
getPipetteNameSpecs(right.pipetteName as PipetteName),
getPipetteSpecsV2(left.pipetteName as PipetteName),
getPipetteSpecsV2(right.pipetteName as PipetteName),
].some(pipetteSpecs => pipetteSpecs && pipetteSpecs.channels !== 1)

const crashablePipetteSelected = getIsCrashablePipetteSelected(
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/components/modals/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function getTiprackOptions(props: TiprackOptionsProps): TiprackOption[] {
const selectedPipetteDefaultTipracks =
selectedPipetteName != null
? getPipetteSpecsV2(selectedPipetteName as PipetteName)
?.liquids[0].defaultTipracks ?? []
?.liquids['default'].defaultTipracks ?? []

Check failure on line 24 in protocol-designer/src/components/modals/utils.ts

View workflow job for this annotation

GitHub Actions / js checks

["default"] is better written in dot notation
: []
const selectedPipetteDisplayCategory =
selectedPipetteName != null
Expand Down
6 changes: 3 additions & 3 deletions protocol-designer/src/components/modules/EditModulesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
HEATERSHAKER_MODULE_TYPE,
ModuleType,
PipetteName,
getPipetteNameSpecs,
FLEX_ROBOT_TYPE,
getPipetteSpecsV2,
} from '@opentrons/shared-data'
import {
selectors as stepFormSelectors,
Expand Down Expand Up @@ -85,8 +85,8 @@ export function EditModulesCard(props: Props): JSX.Element {
const showHeaterShakerPipetteCollisions =
isHeaterShakerOnDeck &&
[
getPipetteNameSpecs(pipettesByMount.left.pipetteName as PipetteName),
getPipetteNameSpecs(pipettesByMount.right.pipetteName as PipetteName),
getPipetteSpecsV2(pipettesByMount.left.pipetteName as PipetteName),
getPipetteSpecsV2(pipettesByMount.right.pipetteName as PipetteName),
].some(pipetteSpecs => pipetteSpecs?.channels !== 1)

const warningsEnabled = !moduleRestrictionsDisabled
Expand Down
17 changes: 9 additions & 8 deletions protocol-designer/src/load-file/migration/1_1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import mapValues from 'lodash/mapValues'
import omit from 'lodash/omit'
import omitBy from 'lodash/omitBy'
import flow from 'lodash/flow'
import { getPipetteNameSpecs } from '@opentrons/shared-data'
import {
import { PipetteName, getPipetteSpecsV2 } from '@opentrons/shared-data'
import { getLegacyLabwareDef } from '../../labware-defs'
import type {
FileLabware,
FilePipette,
ProtocolFile,
} from '@opentrons/shared-data/protocol/types/schemaV1'
import { getLegacyLabwareDef } from '../../labware-defs'
import { FormPatch } from '../../steplist/actions'
import { FormData } from '../../form-types'
import type { FormPatch } from '../../steplist/actions'
import type { FormData } from '../../form-types'

export interface PDMetadata {
pipetteTiprackAssignments: Record<string, string>
dismissedWarnings: {
Expand Down Expand Up @@ -68,12 +69,12 @@ function getPipetteCapacityLegacy(
)}"`
)
}
// @ts-expect-error unable to cast type string from manipulation above to type PipetteName
const specs = getPipetteNameSpecs(pipetteName)

const specs = getPipetteSpecsV2(pipetteName as PipetteName)
const tiprackDef = getLegacyLabwareDef(pipette.tiprackModel)

if (specs && tiprackDef && tiprackDef.metadata.tipVolume) {
return Math.min(specs.maxVolume, tiprackDef.metadata.tipVolume)
return Math.min(specs.liquids['default'].maxVolume, tiprackDef.metadata.tipVolume)

Check failure on line 77 in protocol-designer/src/load-file/migration/1_1_0.ts

View workflow job for this annotation

GitHub Actions / js checks

["default"] is better written in dot notation
}

console.assert(specs, `Expected spec for pipette ${JSON.stringify(pipette)}`)
Expand Down
8 changes: 4 additions & 4 deletions protocol-designer/src/pipettes/pipetteData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DropdownOption } from '../../../components/lib/forms/DropdownField.d'
import {
getPipetteNameSpecs,
getPipetteSpecsV2,
getTiprackVolume,
PipetteName,
} from '@opentrons/shared-data'
Expand All @@ -18,12 +18,12 @@ const supportedPipetteNames: PipetteName[] = [
// TODO: should a version of pipetteOptions be moved to shared-data,
// and used for both PD and Run App?
export const pipetteOptions: Options = supportedPipetteNames
.map((name: PipetteName) => {
const pipette = getPipetteNameSpecs(name)
.map(name => {
const pipette = getPipetteSpecsV2(name)
return pipette
? {
name: pipette.displayName,
value: pipette.name,
value: name as string,
}
: null
})
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/step-forms/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import reduce from 'lodash/reduce'
import isEmpty from 'lodash/isEmpty'
import { createSelector, Selector } from 'reselect'
import {
getPipetteNameSpecs,
getLabwareDisplayName,
getLabwareDefURI,
MAGNETIC_MODULE_TYPE,
Expand All @@ -13,6 +12,7 @@ import {
HEATERSHAKER_MODULE_TYPE,
PipetteName,
MAGNETIC_BLOCK_TYPE,
getPipetteSpecsV2,
} from '@opentrons/shared-data'
import {
AdditionalEquipmentEntities,
Expand Down Expand Up @@ -346,7 +346,7 @@ export const getPermittedTipracks: Selector<
)

function _getPipetteDisplayName(name: PipetteName): string {
const pipetteSpecs = getPipetteNameSpecs(name)
const pipetteSpecs = getPipetteSpecsV2(name)
if (!pipetteSpecs) return 'Unknown Pipette'
return pipetteSpecs.displayName
}
Expand Down
15 changes: 0 additions & 15 deletions protocol-designer/src/step-forms/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import {
getPipetteSpecsV2,
GEN_ONE_MULTI_PIPETTES,
THERMOCYCLER_MODULE_TYPE,
PipetteV2Specs,
} from '@opentrons/shared-data'
import { SPAN7_8_10_11_SLOT, TC_SPAN_SLOTS } from '../../constants'
import { hydrateField } from '../../steplist/fieldLevel'
import { LabwareDefByDefURI } from '../../labware-defs'
import type {
DeckSlotId,
ModuleType,
PipetteChannels,
PipetteNameSpecs,
} from '@opentrons/shared-data'
import type {
AdditionalEquipmentOnDeck,
Expand Down Expand Up @@ -102,18 +99,6 @@ export function denormalizePipetteEntities(
`no pipette spec for pipette id "${pipetteId}", name "${pipette.name}"`
)
}

const pipetteEntitySpecs: PipetteNameSpecs = {
name: pipette.name,
displayName: spec.displayName,
displayCategory: spec.displayCategory,
minVolume: spec.liquids[0].minVolume,
maxVolume: spec.liquids[0].maxVolume,
channels: spec.channels as PipetteChannels,
defaultAspirateFlowRate: spec.liquids[0].supportedTips[0].defaultAspirateFlowRate.default,

// add other properties from spec if needed
}
const pipetteEntity: PipetteEntity = {
...pipette,
spec,
Expand Down
Loading

0 comments on commit f8c7a40

Please sign in to comment.