Skip to content

Commit

Permalink
feat(app,shared-data): get addressable area for legacy fixed trash (#…
Browse files Browse the repository at this point in the history
…14085)

provides a special case for the addressable area of the legacy Flex fixed trash found in older
protocols. parses the labware key of a protocol analysis and inserts addressable area moveableTrashA3
if a legacy fixed trash labware is found. moves the getSimplestDeckConfigForProtocol function to
shared-data and updates references in app and components.

closes RAUT-888
  • Loading branch information
brenthagen authored Dec 4, 2023
1 parent 6c53a94 commit c5a8bf4
Show file tree
Hide file tree
Showing 37 changed files with 382 additions and 523 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function ProtocolRunHeader({
const robotType = isFlex ? FLEX_ROBOT_TYPE : OT2_ROBOT_TYPE
const deckConfigCompatibility = useDeckConfigurationCompatibility(
robotType,
robotProtocolAnalysis?.commands ?? []
robotProtocolAnalysis
)
const isFixtureMismatch = getIsFixtureMismatch(deckConfigCompatibility)

Expand Down
15 changes: 8 additions & 7 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ import {
SPACING,
TYPOGRAPHY,
} from '@opentrons/components'
import { FLEX_ROBOT_TYPE, OT2_ROBOT_TYPE } from '@opentrons/shared-data'
import {
FLEX_ROBOT_TYPE,
getSimplestDeckConfigForProtocol,
OT2_ROBOT_TYPE,
} from '@opentrons/shared-data'

import { Line } from '../../../atoms/structure'
import { StyledText } from '../../../atoms/text'
import { InfoMessage } from '../../../molecules/InfoMessage'
import {
getIsFixtureMismatch,
getRequiredDeckConfig,
getSimplestDeckConfigForProtocolCommands,
} from '../../../resources/deck_configuration/utils'
import { useDeckConfigurationCompatibility } from '../../../resources/deck_configuration/hooks'
import {
Expand Down Expand Up @@ -89,7 +92,7 @@ export function ProtocolRunSetup({
const robotType = isFlex ? FLEX_ROBOT_TYPE : OT2_ROBOT_TYPE
const deckConfigCompatibility = useDeckConfigurationCompatibility(
robotType,
protocolAnalysis?.commands ?? []
protocolAnalysis
)

const isFixtureMismatch = getIsFixtureMismatch(deckConfigCompatibility)
Expand Down Expand Up @@ -134,9 +137,7 @@ export function ProtocolRunSetup({
protocolAnalysis != null && protocolAnalysis.liquids?.length > 0
const hasModules = protocolAnalysis != null && modules.length > 0

const protocolDeckConfig = getSimplestDeckConfigForProtocolCommands(
protocolAnalysis?.commands ?? []
)
const protocolDeckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis)

const requiredDeckConfig = getRequiredDeckConfig(protocolDeckConfig)

Expand Down Expand Up @@ -185,7 +186,7 @@ export function ProtocolRunSetup({
robotName={robotName}
runId={runId}
hasModules={hasModules}
commands={protocolAnalysis?.commands ?? []}
protocolAnalysis={protocolAnalysis}
/>
),
description: moduleDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
import {
FLEX_ROBOT_TYPE,
getDeckDefFromRobotType,
getSimplestDeckConfigForProtocol,
THERMOCYCLER_MODULE_V1,
} from '@opentrons/shared-data'

import { getLabwareSetupItemGroups } from '../../../../pages/Protocols/utils'
import { getSimplestDeckConfigForProtocolCommands } from '../../../../resources/deck_configuration/utils'
import { getAttachedProtocolModuleMatches } from '../../../ProtocolSetupModulesAndDeck/utils'
import { useAttachedModules } from '../../hooks'
import { LabwareInfoOverlay } from '../LabwareInfoOverlay'
Expand Down Expand Up @@ -106,9 +106,7 @@ export function SetupLabwareMap({

const { offDeckItems } = getLabwareSetupItemGroups(commands)

const deckConfig = getSimplestDeckConfigForProtocolCommands(
protocolAnalysis.commands
)
const deckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis)

const labwareRenderInfo = getLabwareRenderInfo(protocolAnalysis, deckDef)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import {
FLEX_ROBOT_TYPE,
getDeckDefFromRobotType,
getSimplestDeckConfigForProtocol,
THERMOCYCLER_MODULE_V1,
} from '@opentrons/shared-data'

Expand All @@ -25,7 +26,6 @@ import { LabwareInfoOverlay } from '../LabwareInfoOverlay'
import { LiquidsLabwareDetailsModal } from './LiquidsLabwareDetailsModal'
import { getWellFillFromLabwareId } from './utils'
import { getLabwareRenderInfo } from '../utils/getLabwareRenderInfo'
import { getSimplestDeckConfigForProtocolCommands } from '../../../../resources/deck_configuration/utils'
import { getStandardDeckViewLayerBlockList } from '../utils/getStandardDeckViewLayerBlockList'
import { getAttachedProtocolModuleMatches } from '../../../ProtocolSetupModulesAndDeck/utils'
import { getProtocolModulesInfo } from '../utils/getProtocolModulesInfo'
Expand Down Expand Up @@ -70,9 +70,7 @@ export function SetupLiquidsMap(
const labwareByLiquidId = parseLabwareInfoByLiquidId(
protocolAnalysis.commands ?? []
)
const deckConfig = getSimplestDeckConfigForProtocolCommands(
protocolAnalysis.commands
)
const deckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis)
const deckLayerBlocklist = getStandardDeckViewLayerBlockList(robotType)

const protocolModulesInfo = getProtocolModulesInfo(protocolAnalysis, deckDef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import fixture_tiprack_300_ul from '@opentrons/shared-data/labware/fixtures/2/fi
import {
FLEX_ROBOT_TYPE,
getDeckDefFromRobotType,
getSimplestDeckConfigForProtocol,
OT2_ROBOT_TYPE,
} from '@opentrons/shared-data'
import {
Expand All @@ -29,7 +30,6 @@ import { getLabwareRenderInfo } from '../../utils/getLabwareRenderInfo'
import { getStandardDeckViewLayerBlockList } from '../../utils/getStandardDeckViewLayerBlockList'
import { getAttachedProtocolModuleMatches } from '../../../../ProtocolSetupModulesAndDeck/utils'
import { getProtocolModulesInfo } from '../../utils/getProtocolModulesInfo'
import { getSimplestDeckConfigForProtocolCommands } from '../../../../../resources/deck_configuration/utils'
import { mockProtocolModuleInfo } from '../../../../ProtocolSetupLabware/__fixtures__'
import { mockFetchModulesSuccessActionPayloadModules } from '../../../../../redux/modules/__fixtures__'

Expand All @@ -38,7 +38,6 @@ import { SetupLiquidsMap } from '../SetupLiquidsMap'
import type {
ModuleModel,
ModuleType,
RunTimeCommand,
LabwareDefinition2,
} from '@opentrons/shared-data'

Expand Down Expand Up @@ -92,8 +91,8 @@ const mockGetAttachedProtocolModuleMatches = getAttachedProtocolModuleMatches as
const mockGetProtocolModulesInfo = getProtocolModulesInfo as jest.MockedFunction<
typeof getProtocolModulesInfo
>
const mockGetSimplestDeckConfigForProtocolCommands = getSimplestDeckConfigForProtocolCommands as jest.MockedFunction<
typeof getSimplestDeckConfigForProtocolCommands
const mockGetSimplestDeckConfigForProtocol = getSimplestDeckConfigForProtocol as jest.MockedFunction<
typeof getSimplestDeckConfigForProtocol
>

const RUN_ID = '1'
Expand Down Expand Up @@ -163,8 +162,8 @@ describe('SetupLiquidsMap', () => {
when(mockGetLabwareRenderInfo)
.calledWith(mockProtocolAnalysis, ot2StandardDeckDef as any)
.mockReturnValue({})
when(mockGetSimplestDeckConfigForProtocolCommands)
.calledWith(mockProtocolAnalysis.commands as RunTimeCommand[])
when(mockGetSimplestDeckConfigForProtocol)
.calledWith(mockProtocolAnalysis)
// TODO(bh, 2023-11-13): mock the cutout config protocol spec
.mockReturnValue([])
when(mockParseLiquidsInLoadOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from '@opentrons/components'
import {
FLEX_ROBOT_TYPE,
getCutoutIdForSlotName,
getDeckDefFromRobotType,
getModuleType,
HEATERSHAKER_MODULE_TYPE,
Expand All @@ -35,7 +36,6 @@ import { TertiaryButton } from '../../../../atoms/buttons'
import { StatusLabel } from '../../../../atoms/StatusLabel'
import { StyledText } from '../../../../atoms/text'
import { Tooltip } from '../../../../atoms/Tooltip'
import { getCutoutIdForSlotName } from '../../../../resources/deck_configuration/utils'
import { useChainLiveCommands } from '../../../../resources/runs/hooks'
import { ModuleSetupModal } from '../../../ModuleCard/ModuleSetupModal'
import { ModuleWizardFlows } from '../../../ModuleWizardFlows'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
import {
FLEX_ROBOT_TYPE,
getDeckDefFromRobotType,
getSimplestDeckConfigForProtocol,
} from '@opentrons/shared-data'

import { getSimplestDeckConfigForProtocolCommands } from '../../../../resources/deck_configuration/utils'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { getAttachedProtocolModuleMatches } from '../../../ProtocolSetupModulesAndDeck/utils'
import { ModuleInfo } from '../../ModuleInfo'
Expand Down Expand Up @@ -64,9 +64,7 @@ export const SetupModulesMap = ({
),
}))

const deckConfig = getSimplestDeckConfigForProtocolCommands(
protocolAnalysis.commands
)
const deckConfig = getSimplestDeckConfigForProtocol(protocolAnalysis)

return (
<Flex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('SetupModuleAndDeck', () => {
runId: MOCK_RUN_ID,
expandLabwarePositionCheckStep: () => jest.fn(),
hasModules: true,
commands: [],
protocolAnalysis: null,
}
mockSetupFixtureList.mockReturnValue(<div>Mock setup fixture list</div>)
mockSetupModulesList.mockReturnValue(<div>Mock setup modules list</div>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@ import { SetupModulesMap } from './SetupModulesMap'
import { SetupModulesList } from './SetupModulesList'
import { SetupFixtureList } from './SetupFixtureList'

import type { RunTimeCommand } from '@opentrons/shared-data'
import type {
CompletedProtocolAnalysis,
ProtocolAnalysisOutput,
} from '@opentrons/shared-data'

interface SetupModuleAndDeckProps {
expandLabwarePositionCheckStep: () => void
robotName: string
runId: string
hasModules: boolean
commands: RunTimeCommand[]
protocolAnalysis: CompletedProtocolAnalysis | ProtocolAnalysisOutput | null
}

export const SetupModuleAndDeck = ({
expandLabwarePositionCheckStep,
robotName,
runId,
hasModules,
commands,
protocolAnalysis,
}: SetupModuleAndDeckProps): JSX.Element => {
const { t } = useTranslation('protocol_setup')
const [selectedValue, toggleGroup] = useToggleGroup(
Expand All @@ -58,7 +61,7 @@ export const SetupModuleAndDeck = ({
const moduleCalibrationStatus = useModuleCalibrationStatus(robotName, runId)
const deckConfigCompatibility = useDeckConfigurationCompatibility(
robotType,
commands
protocolAnalysis
)

const isFixtureMismatch = getIsFixtureMismatch(deckConfigCompatibility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
renderWithProviders,
} from '@opentrons/components'
import {
getSimplestDeckConfigForProtocol,
ProtocolAnalysisOutput,
STAGING_AREA_SLOT_WITH_WASTE_CHUTE_RIGHT_ADAPTER_NO_COVER_FIXTURE,
} from '@opentrons/shared-data'
Expand All @@ -18,7 +19,6 @@ import { mockConnectedRobot } from '../../../../redux/discovery/__fixtures__'
import {
getIsFixtureMismatch,
getRequiredDeckConfig,
getSimplestDeckConfigForProtocolCommands,
} from '../../../../resources/deck_configuration/utils'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useDeckConfigurationCompatibility } from '../../../../resources/deck_configuration/hooks'
Expand Down Expand Up @@ -48,6 +48,7 @@ jest.mock('../SetupLiquids')
jest.mock('../EmptySetupStep')
jest.mock('../../../LabwarePositionCheck/useMostRecentCompletedAnalysis')
jest.mock('@opentrons/shared-data/js/helpers/parseProtocolData')
jest.mock('@opentrons/shared-data/js/helpers/getSimplestFlexDeckConfig')
jest.mock('../../../../redux/config')
jest.mock('../../../../resources/deck_configuration/utils')
jest.mock('../../../../resources/deck_configuration/hooks')
Expand Down Expand Up @@ -90,8 +91,8 @@ const mockSetupLiquids = SetupLiquids as jest.MockedFunction<
const mockEmptySetupStep = EmptySetupStep as jest.MockedFunction<
typeof EmptySetupStep
>
const mockGetSimplestDeckConfigForProtocolCommands = getSimplestDeckConfigForProtocolCommands as jest.MockedFunction<
typeof getSimplestDeckConfigForProtocolCommands
const mockGetSimplestDeckConfigForProtocol = getSimplestDeckConfigForProtocol as jest.MockedFunction<
typeof getSimplestDeckConfigForProtocol
>
const mockGetRequiredDeckConfig = getRequiredDeckConfig as jest.MockedFunction<
typeof getRequiredDeckConfig
Expand Down Expand Up @@ -168,7 +169,7 @@ describe('ProtocolRunSetup', () => {
when(mockSetupModuleAndDeck).mockReturnValue(<div>Mock SetupModules</div>)
when(mockSetupLiquids).mockReturnValue(<div>Mock SetupLiquids</div>)
when(mockEmptySetupStep).mockReturnValue(<div>Mock EmptySetupStep</div>)
when(mockGetSimplestDeckConfigForProtocolCommands).mockReturnValue([])
when(mockGetSimplestDeckConfigForProtocol).mockReturnValue([])
when(mockUseDeckConfigurationCompatibility).mockReturnValue([])
when(mockGetRequiredDeckConfig).mockReturnValue([])
when(mockUseUnmatchedModulesForProtocol)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
checkModuleCompatibility,
FLEX_ROBOT_TYPE,
getCutoutIdForSlotName,
getDeckDefFromRobotType,
SINGLE_SLOT_FIXTURES,
} from '@opentrons/shared-data'
import { useDeckConfigurationQuery } from '@opentrons/react-api-client/src/deck_configuration'

import { getCutoutIdForSlotName } from '../../../resources/deck_configuration/utils'
import { getProtocolModulesInfo } from '../ProtocolRun/utils/getProtocolModulesInfo'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useAttachedModules } from './useAttachedModules'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import { getRobotTypeDisplayName } from '../ProtocolsLanding/utils'
import { getSlotsForThermocycler } from './utils'

import type {
CutoutConfigProtocolSpec,
LoadModuleRunTimeCommand,
PipetteName,
RobotType,
SingleSlotCutoutFixtureId,
} from '@opentrons/shared-data'
import type { CutoutConfigProtocolSpec } from '../../resources/deck_configuration/utils'

interface RobotConfigurationDetailsProps {
leftMountPipetteName: PipetteName | null
Expand Down
10 changes: 6 additions & 4 deletions app/src/organisms/ProtocolDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import {
parseInitialLoadedLabwareByModuleId,
parseInitialLoadedLabwareByAdapter,
} from '@opentrons/api-client'
import { getGripperDisplayName } from '@opentrons/shared-data'
import {
getGripperDisplayName,
getSimplestDeckConfigForProtocol,
} from '@opentrons/shared-data'

import { Portal } from '../../App/portal'
import { Divider } from '../../atoms/structure'
Expand All @@ -54,7 +57,6 @@ import {
analyzeProtocol,
} from '../../redux/protocol-storage'
import { useFeatureFlag } from '../../redux/config'
import { getSimplestDeckConfigForProtocolCommands } from '../../resources/deck_configuration/utils'
import { ChooseRobotToRunProtocolSlideout } from '../ChooseRobotToRunProtocolSlideout'
import { SendProtocolToOT3Slideout } from '../SendProtocolToOT3Slideout'
import { ProtocolAnalysisFailure } from '../ProtocolAnalysisFailure'
Expand Down Expand Up @@ -230,8 +232,8 @@ export function ProtocolDetails(
? map(parseInitialLoadedModulesBySlot(mostRecentAnalysis.commands))
: []

const requiredFixtureDetails = getSimplestDeckConfigForProtocolCommands(
mostRecentAnalysis?.commands ?? []
const requiredFixtureDetails = getSimplestDeckConfigForProtocol(
mostRecentAnalysis
)

const requiredLabwareDetails =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { i18n } from '../../../i18n'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { ProtocolSetupDeckConfiguration } from '..'

import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'

jest.mock('@opentrons/components/src/hardware-sim/BaseDeck/index')
jest.mock('@opentrons/react-api-client')
jest.mock('../../LabwarePositionCheck/useMostRecentCompletedAnalysis')
Expand All @@ -16,7 +18,10 @@ const mockSetSetupScreen = jest.fn()
const mockUpdateDeckConfiguration = jest.fn()
const PROTOCOL_DETAILS = {
displayName: 'fake protocol',
protocolData: [],
protocolData: ({
commands: [],
labware: [],
} as unknown) as CompletedProtocolAnalysis,
protocolKey: 'fakeProtocolKey',
robotType: 'OT-3 Standard' as const,
}
Expand Down Expand Up @@ -50,7 +55,7 @@ describe('ProtocolSetupDeckConfiguration', () => {
mockBaseDeck.mockReturnValue(<div>mock BaseDeck</div>)
when(mockUseMostRecentCompletedAnalysis)
.calledWith('mockRunId')
.mockReturnValue(PROTOCOL_DETAILS.protocolData as any)
.mockReturnValue(PROTOCOL_DETAILS.protocolData)
mockUseUpdateDeckConfigurationMutation.mockReturnValue({
updateDeckConfiguration: mockUpdateDeckConfiguration,
} as any)
Expand Down
Loading

0 comments on commit c5a8bf4

Please sign in to comment.