From bd7270064ca63df946799db4dad6e78d6a95f775 Mon Sep 17 00:00:00 2001 From: Shlok Amin Date: Thu, 22 Feb 2024 16:23:52 -0500 Subject: [PATCH] replace assert with console.assert --- .../useOnClickOutside.ts | 2 +- .../LabwareOverlays/AdapterControls.tsx | 4 ++-- .../LabwareOverlays/SlotControls.tsx | 4 ++-- .../LabwareDetailsCard/LabwareDetailsCard.tsx | 6 +++--- .../LiquidPlacementForm.tsx | 10 +++++----- .../src/components/LiquidPlacementModal.tsx | 4 ++-- .../src/components/LiquidsPage/index.tsx | 4 ++-- .../fields/TipPositionField/utils.ts | 4 ++-- .../src/components/alerts/Alerts.tsx | 4 ++-- .../components/labware/BrowsableLabware.tsx | 4 ++-- .../components/labware/BrowseLabwareModal.tsx | 4 ++-- .../modals/FilePipettesModal/index.tsx | 4 ++-- .../FileUploadMessageModal/modalContents.tsx | 4 ++-- .../LabwareUploadMessageModal.tsx | 6 +++--- .../src/file-data/selectors/fileCreator.ts | 2 +- .../src/labware-defs/__mocks__/utils.ts | 4 ++-- protocol-designer/src/labware-defs/actions.ts | 4 ++-- .../src/labware-ingred/actions/thunks.ts | 4 ++-- .../src/load-file/migration/1_1_0.ts | 8 ++++---- protocol-designer/src/persist.ts | 4 ++-- protocol-designer/src/pipettes/pipetteData.ts | 6 +++--- .../src/step-forms/reducers/index.ts | 10 +++++----- .../src/step-forms/selectors/index.ts | 6 +++--- .../src/step-forms/utils/index.ts | 10 +++++----- .../dependentFieldsUpdateMoveLiquid.ts | 4 ++-- .../formLevel/handleFormChange/utils.ts | 8 ++++---- .../stepFormToArgs/heaterShakerFormToArgs.ts | 6 +++--- .../stepFormToArgs/magnetFormToArgs.ts | 4 ++-- .../formLevel/stepFormToArgs/mixFormToArgs.ts | 4 ++-- .../stepFormToArgs/moveLiquidFormToArgs.ts | 12 +++++------ .../stepFormToArgs/temperatureFormToArgs.ts | 4 ++-- .../test/moveLiquidFormToArgs.test.ts | 2 +- .../src/steplist/generateSubstepItem.ts | 6 +++--- .../src/top-selectors/timelineFrames.ts | 4 ++-- .../src/ui/steps/actions/thunks/index.ts | 20 +++++++++---------- .../src/utils/labwareModuleCompatibility.ts | 4 ++-- shared-data/js/helpers/index.ts | 5 ++--- 37 files changed, 102 insertions(+), 103 deletions(-) diff --git a/components/src/interaction-enhancers/useOnClickOutside.ts b/components/src/interaction-enhancers/useOnClickOutside.ts index 8ec38713773..a81ffba9910 100644 --- a/components/src/interaction-enhancers/useOnClickOutside.ts +++ b/components/src/interaction-enhancers/useOnClickOutside.ts @@ -17,7 +17,7 @@ export const useOnClickOutside = ( const handleClickOutside = (event: MouseEvent): void => { const clickedElem = event.target - assert( + console.assert( clickedElem instanceof Node, 'expected clicked element to be Node - something went wrong in onClickOutside hook' ) diff --git a/protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx b/protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx index 167827b073e..e68fd120625 100644 --- a/protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx +++ b/protocol-designer/src/components/DeckSetup/LabwareOverlays/AdapterControls.tsx @@ -1,4 +1,4 @@ -import assert from 'assert' + import * as React from 'react' import { DropTarget, DropTargetConnector, DropTargetMonitor } from 'react-dnd' import cx from 'classnames' @@ -175,7 +175,7 @@ const slotTarget = { canDrop: (props: SlotControlsProps, monitor: DropTargetMonitor) => { const draggedItem = monitor.getItem() const draggedDef = draggedItem?.labwareOnDeck?.def - assert(draggedDef, 'no labware def of dragged item, expected it on drop') + console.assert(draggedDef, 'no labware def of dragged item, expected it on drop') if (draggedDef != null) { const isCustomLabware = getLabwareIsCustom( diff --git a/protocol-designer/src/components/DeckSetup/LabwareOverlays/SlotControls.tsx b/protocol-designer/src/components/DeckSetup/LabwareOverlays/SlotControls.tsx index 500584feb7a..283f2c5bbf3 100644 --- a/protocol-designer/src/components/DeckSetup/LabwareOverlays/SlotControls.tsx +++ b/protocol-designer/src/components/DeckSetup/LabwareOverlays/SlotControls.tsx @@ -1,4 +1,4 @@ -import assert from 'assert' + import * as React from 'react' import { useTranslation } from 'react-i18next' import { connect } from 'react-redux' @@ -174,7 +174,7 @@ const slotTarget = { const draggedItem = monitor.getItem() const draggedDef = draggedItem?.labwareOnDeck?.def const moduleType = props.moduleType - assert(draggedDef, 'no labware def of dragged item, expected it on drop') + console.assert(draggedDef, 'no labware def of dragged item, expected it on drop') if (moduleType != null && draggedDef != null) { // this is a module slot, prevent drop if the dragged labware is not compatible diff --git a/protocol-designer/src/components/IngredientsList/LabwareDetailsCard/LabwareDetailsCard.tsx b/protocol-designer/src/components/IngredientsList/LabwareDetailsCard/LabwareDetailsCard.tsx index 9b57bac7786..2272301a985 100644 --- a/protocol-designer/src/components/IngredientsList/LabwareDetailsCard/LabwareDetailsCard.tsx +++ b/protocol-designer/src/components/IngredientsList/LabwareDetailsCard/LabwareDetailsCard.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import assert from 'assert' + import { useDispatch, useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' import cx from 'classnames' @@ -26,13 +26,13 @@ export function LabwareDetailsCard(): JSX.Element { ? getLabwareDisplayName(labwareEntities[labwareId].def) : null - assert( + console.assert( labwareId, 'Expected labware id to exist in connected labware details card' ) const renameLabware = (name: string): void => { - assert( + console.assert( labwareId, 'renameLabware in LabwareDetailsCard expected a labwareId' ) diff --git a/protocol-designer/src/components/LiquidPlacementForm/LiquidPlacementForm.tsx b/protocol-designer/src/components/LiquidPlacementForm/LiquidPlacementForm.tsx index 72f46354182..aaba1ea3262 100644 --- a/protocol-designer/src/components/LiquidPlacementForm/LiquidPlacementForm.tsx +++ b/protocol-designer/src/components/LiquidPlacementForm/LiquidPlacementForm.tsx @@ -3,7 +3,7 @@ import { Controller, useForm } from 'react-hook-form' import isEmpty from 'lodash/isEmpty' import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' -import assert from 'assert' + import * as wellContentsSelectors from '../../top-selectors/well-contents' import * as fieldProcessors from '../../steplist/fieldLevel/processing' import { @@ -118,23 +118,23 @@ export const LiquidPlacementForm = (): JSX.Element | null => { const handleSaveForm = (values: LiquidPlacementFormValues): void => { const volume = Number(values.volume) const { selectedLiquidId } = values - assert( + console.assert( labwareId != null, 'when saving liquid placement form, expected a selected labware ID' ) - assert( + console.assert( selectedWells && selectedWells.length > 0, `when saving liquid placement form, expected selected wells to be array with length > 0 but got ${String( selectedWells )}` ) - assert( + console.assert( selectedLiquidId != null, `when saving liquid placement form, expected selectedLiquidId to be non-nullsy but got ${String( selectedLiquidId )}` ) - assert( + console.assert( volume > 0, `when saving liquid placement form, expected volume > 0, got ${volume}` ) diff --git a/protocol-designer/src/components/LiquidPlacementModal.tsx b/protocol-designer/src/components/LiquidPlacementModal.tsx index d4e22476707..d5184173f6b 100644 --- a/protocol-designer/src/components/LiquidPlacementModal.tsx +++ b/protocol-designer/src/components/LiquidPlacementModal.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import assert from 'assert' + import { useDispatch, useSelector } from 'react-redux' import cx from 'classnames' import isEmpty from 'lodash/isEmpty' @@ -33,7 +33,7 @@ export function LiquidPlacementModal(): JSX.Element { const liquidNamesById = useSelector(selectors.getLiquidNamesById) const liquidDisplayColors = useSelector(selectors.getLiquidDisplayColors) if (labwareId == null) { - assert( + console.assert( false, 'LiquidPlacementModal: No labware is selected, and no labwareId was given to LiquidPlacementModal' ) diff --git a/protocol-designer/src/components/LiquidsPage/index.tsx b/protocol-designer/src/components/LiquidsPage/index.tsx index 13c8c4392c9..de1fbcc7c78 100644 --- a/protocol-designer/src/components/LiquidsPage/index.tsx +++ b/protocol-designer/src/components/LiquidsPage/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { useDispatch, useSelector } from 'react-redux' -import assert from 'assert' + import * as labwareIngredActions from '../../labware-ingred/actions' import { selectors as labwareIngredSelectors } from '../../labware-ingred/selectors' @@ -45,7 +45,7 @@ export function LiquidsPage(): JSX.Element { }) ) } - assert( + console.assert( !(liquidGroupId && !selectedIngredFields), `Expected selected liquid group "${String( liquidGroupId diff --git a/protocol-designer/src/components/StepEditForm/fields/TipPositionField/utils.ts b/protocol-designer/src/components/StepEditForm/fields/TipPositionField/utils.ts index cc833151f87..1b959780579 100644 --- a/protocol-designer/src/components/StepEditForm/fields/TipPositionField/utils.ts +++ b/protocol-designer/src/components/StepEditForm/fields/TipPositionField/utils.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { DEFAULT_MM_FROM_BOTTOM_ASPIRATE, DEFAULT_MM_FROM_BOTTOM_DISPENSE, @@ -35,7 +35,7 @@ export function getDefaultMmFromBottom(args: { default: // touch tip fields - assert( + console.assert( getIsTouchTipField(name), `getDefaultMmFromBottom fn does not know what to do with field ${name}` ) diff --git a/protocol-designer/src/components/alerts/Alerts.tsx b/protocol-designer/src/components/alerts/Alerts.tsx index 1dee5380657..4de93d17a55 100644 --- a/protocol-designer/src/components/alerts/Alerts.tsx +++ b/protocol-designer/src/components/alerts/Alerts.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import assert from 'assert' + import { useTranslation } from 'react-i18next' import { useSelector, useDispatch } from 'react-redux' import * as timelineWarningSelectors from '../../top-selectors/timelineWarnings' @@ -116,7 +116,7 @@ const AlertsComponent = (props: Props): JSX.Element => { } } const makeHandleCloseWarning = (dismissId?: string | null) => () => { - assert(dismissId, 'expected dismissId, Alert cannot dismiss warning') + console.assert(dismissId, 'expected dismissId, Alert cannot dismiss warning') if (dismissId) { dismissWarning(dismissId) } diff --git a/protocol-designer/src/components/labware/BrowsableLabware.tsx b/protocol-designer/src/components/labware/BrowsableLabware.tsx index 56d5104421f..f4400058fc6 100644 --- a/protocol-designer/src/components/labware/BrowsableLabware.tsx +++ b/protocol-designer/src/components/labware/BrowsableLabware.tsx @@ -1,4 +1,4 @@ -import assert from 'assert' + import * as React from 'react' import { useSelector } from 'react-redux' import reduce from 'lodash/reduce' @@ -23,7 +23,7 @@ export function BrowsableLabware(props: Props): JSX.Element | null { const { definition, ingredNames, wellContents } = props const liquidDisplayColors = useSelector(selectors.getLiquidDisplayColors) if (!definition) { - assert(definition, 'BrowseLabwareModal expected definition') + console.assert(definition, 'BrowseLabwareModal expected definition') return null } diff --git a/protocol-designer/src/components/labware/BrowseLabwareModal.tsx b/protocol-designer/src/components/labware/BrowseLabwareModal.tsx index 16388f35de4..35b6c96a0ea 100644 --- a/protocol-designer/src/components/labware/BrowseLabwareModal.tsx +++ b/protocol-designer/src/components/labware/BrowseLabwareModal.tsx @@ -1,4 +1,4 @@ -import assert from 'assert' + import * as React from 'react' import cx from 'classnames' import { useDispatch, useSelector } from 'react-redux' @@ -30,7 +30,7 @@ export const BrowseLabwareModal = (): JSX.Element | null => { : null if (!definition) { - assert(definition, 'BrowseLabwareModal expected definition') + console.assert(definition, 'BrowseLabwareModal expected definition') return null } diff --git a/protocol-designer/src/components/modals/FilePipettesModal/index.tsx b/protocol-designer/src/components/modals/FilePipettesModal/index.tsx index 2396bababd7..21aa955859f 100644 --- a/protocol-designer/src/components/modals/FilePipettesModal/index.tsx +++ b/protocol-designer/src/components/modals/FilePipettesModal/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import assert from 'assert' + import { useForm } from 'react-hook-form' import { yupResolver } from '@hookform/resolvers/yup' import reduce from 'lodash/reduce' @@ -354,7 +354,7 @@ export const FilePipettesModal = (props: Props): JSX.Element => { const pipettes = reduce( values.pipettesByMount, (acc, formPipette: FormPipette, mount): PipetteFieldsData[] => { - assert(mount === 'left' || mount === 'right', `invalid mount: ${mount}`) // this is mostly for flow + console.assert(mount === 'left' || mount === 'right', `invalid mount: ${mount}`) // this is mostly for flow // @ts-expect-error(sa, 2021-6-21): TODO validate that pipette names coming from the modal are actually valid pipette names on PipetteName type return formPipette && formPipette.pipetteName && diff --git a/protocol-designer/src/components/modals/FileUploadMessageModal/modalContents.tsx b/protocol-designer/src/components/modals/FileUploadMessageModal/modalContents.tsx index 35dfd08ee47..cb323c80ce4 100644 --- a/protocol-designer/src/components/modals/FileUploadMessageModal/modalContents.tsx +++ b/protocol-designer/src/components/modals/FileUploadMessageModal/modalContents.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { Trans, useTranslation } from 'react-i18next' -import assert from 'assert' + import styles from './modalContents.module.css' import { FileUploadMessage } from '../../../load-file' import type { ModalContents } from './types' @@ -191,7 +191,7 @@ export function useModalContents( t, }) default: { - assert( + console.assert( false, `invalid messageKey ${uploadResponse.messageKey} specified for modal` ) diff --git a/protocol-designer/src/components/modals/LabwareUploadMessageModal/LabwareUploadMessageModal.tsx b/protocol-designer/src/components/modals/LabwareUploadMessageModal/LabwareUploadMessageModal.tsx index f1410865757..38443d4e383 100644 --- a/protocol-designer/src/components/modals/LabwareUploadMessageModal/LabwareUploadMessageModal.tsx +++ b/protocol-designer/src/components/modals/LabwareUploadMessageModal/LabwareUploadMessageModal.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { useDispatch, useSelector } from 'react-redux' import { useTranslation } from 'react-i18next' -import assert from 'assert' + import cx from 'classnames' import { AlertModal, OutlineButton, ButtonProps } from '@opentrons/components' import modalStyles from '../modal.module.css' @@ -80,7 +80,7 @@ const MessageBody = (props: { ) } - assert(false, `MessageBody got unhandled messageType: ${message.messageType}`) + console.assert(false, `MessageBody got unhandled messageType: ${message.messageType}`) return null } @@ -107,7 +107,7 @@ export const LabwareUploadMessageModal = (): JSX.Element | null => { }) ) } else { - assert( + console.assert( false, `labware def should only be overwritten when messageType is ASK_FOR_LABWARE_OVERWRITE. Got ${String( message?.messageType diff --git a/protocol-designer/src/file-data/selectors/fileCreator.ts b/protocol-designer/src/file-data/selectors/fileCreator.ts index 2a842c50072..1d79db11161 100644 --- a/protocol-designer/src/file-data/selectors/fileCreator.ts +++ b/protocol-designer/src/file-data/selectors/fileCreator.ts @@ -62,7 +62,7 @@ import type { import type { Selector } from '../../types' // TODO: BC: 2018-02-21 uncomment this assert, causes test failures -// assert(!isEmpty(process.env.OT_PD_VERSION), 'Could not find application version!') +// console.assert(!isEmpty(process.env.OT_PD_VERSION), 'Could not find application version!') if (isEmpty(process.env.OT_PD_VERSION)) console.warn('Could not find application version!') const applicationVersion: string = process.env.OT_PD_VERSION || '' diff --git a/protocol-designer/src/labware-defs/__mocks__/utils.ts b/protocol-designer/src/labware-defs/__mocks__/utils.ts index 073286f0224..3a33f207a27 100644 --- a/protocol-designer/src/labware-defs/__mocks__/utils.ts +++ b/protocol-designer/src/labware-defs/__mocks__/utils.ts @@ -1,5 +1,5 @@ // replace webpack-specific require.context with Node-based glob in tests -import assert from 'assert' + import { vi } from 'vitest' import path from 'path' import glob from 'glob' @@ -16,7 +16,7 @@ const allLabware: LabwareDefByDefURI = glob .map(require) .filter(d => d.metadata.displayCategory !== 'trash') .reduce((acc, d) => ({ ...acc, [getLabwareDefURI(d)]: d }), {}) -assert( +console.assert( Object.keys(allLabware).length > 0, `no labware fixtures found, is the path correct? ${LABWARE_FIXTURE_PATTERN}` ) diff --git a/protocol-designer/src/labware-defs/actions.ts b/protocol-designer/src/labware-defs/actions.ts index 43ab1673a02..21f75e8d9b7 100644 --- a/protocol-designer/src/labware-defs/actions.ts +++ b/protocol-designer/src/labware-defs/actions.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import Ajv from 'ajv' import isEqual from 'lodash/isEqual' import flatten from 'lodash/flatten' @@ -186,7 +186,7 @@ const _createCustomLabwareDef: ( ...defsMatchingCustomLoadName, ...defsMatchingCustomDisplayName, ] - assert( + console.assert( uniqBy(matchingDefs, getLabwareDefURI).length === 1, 'expected exactly 1 matching labware def to ask to overwrite' ) diff --git a/protocol-designer/src/labware-ingred/actions/thunks.ts b/protocol-designer/src/labware-ingred/actions/thunks.ts index ca9f6b00eee..d6f6e5ff082 100644 --- a/protocol-designer/src/labware-ingred/actions/thunks.ts +++ b/protocol-designer/src/labware-ingred/actions/thunks.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { getIsTiprack } from '@opentrons/shared-data' import { uuid } from '../../utils' import { selectors as labwareDefSelectors } from '../../labware-defs' @@ -116,7 +116,7 @@ export const duplicateLabware: ( const templateLabwareDefURI = stepFormSelectors.getLabwareEntities(state)[ templateLabwareId ].labwareDefURI - assert( + console.assert( templateLabwareDefURI, `no labwareDefURI for labware ${templateLabwareId}, cannot run duplicateLabware thunk` ) diff --git a/protocol-designer/src/load-file/migration/1_1_0.ts b/protocol-designer/src/load-file/migration/1_1_0.ts index 26e9abc0775..3c9a19ed6be 100644 --- a/protocol-designer/src/load-file/migration/1_1_0.ts +++ b/protocol-designer/src/load-file/migration/1_1_0.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import isUndefined from 'lodash/isUndefined' import mapValues from 'lodash/mapValues' import omit from 'lodash/omit' @@ -77,12 +77,12 @@ function getPipetteCapacityLegacy( return Math.min(specs.maxVolume, tiprackDef.metadata.tipVolume) } - assert(specs, `Expected spec for pipette ${JSON.stringify(pipette)}`) - assert( + console.assert(specs, `Expected spec for pipette ${JSON.stringify(pipette)}`) + console.assert( tiprackDef, `expected tiprack def for pipette ${JSON.stringify(pipette)}` ) - assert( + console.assert( tiprackDef?.metadata?.tipVolume, `expected tiprack volume for tiprack def ${JSON.stringify( tiprackDef?.metadata || 'undefined' diff --git a/protocol-designer/src/persist.ts b/protocol-designer/src/persist.ts index bf8685d1548..42edf18dc16 100644 --- a/protocol-designer/src/persist.ts +++ b/protocol-designer/src/persist.ts @@ -1,5 +1,5 @@ import get from 'lodash/get' -import assert from 'assert' + import { Store } from 'redux' import { dismissedHintsPersist } from './tutorial/reducers' export interface RehydratePersistedAction { @@ -22,7 +22,7 @@ export const getLocalStorageItem = (path: string): unknown => { } // The `path` should match where the reducer lives in the Redux state tree export const _rehydrate = (path: string): any => { - assert( + console.assert( PERSISTED_PATHS.includes(path), `Path "${path}" is missing from PERSISTED_PATHS! The changes to this reducer will not be persisted.` ) diff --git a/protocol-designer/src/pipettes/pipetteData.ts b/protocol-designer/src/pipettes/pipetteData.ts index bccd7136206..067faf4cc32 100644 --- a/protocol-designer/src/pipettes/pipetteData.ts +++ b/protocol-designer/src/pipettes/pipetteData.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { DropdownOption } from '../../../components/lib/forms/DropdownField.d' import { getPipetteNameSpecs, @@ -42,7 +42,7 @@ export function getPipetteCapacity(pipetteEntity: PipetteEntity): number { return Math.min(spec.maxVolume, getTiprackVolume(tiprackDef)) } - assert( + console.assert( false, `Expected spec and tiprack def for pipette ${ pipetteEntity ? pipetteEntity.id : '???' @@ -57,7 +57,7 @@ export function getMinPipetteVolume(pipetteEntity: PipetteEntity): number { return spec.minVolume } - assert( + console.assert( false, `Expected spec for pipette ${pipetteEntity ? pipetteEntity.id : '???'}` ) diff --git a/protocol-designer/src/step-forms/reducers/index.ts b/protocol-designer/src/step-forms/reducers/index.ts index 0c37965a6f5..013b6a5d5a6 100644 --- a/protocol-designer/src/step-forms/reducers/index.ts +++ b/protocol-designer/src/step-forms/reducers/index.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { handleActions } from 'redux-actions' import { Reducer } from 'redux' import mapValues from 'lodash/mapValues' @@ -534,7 +534,7 @@ export const _editModuleFormUpdate = ({ ? getLabwareDefaultEngageHeight(labwareEntity.def) : null const moduleEntity = initialDeckSetup.modules[moduleId] - assert( + console.assert( moduleEntity, `editModuleFormUpdate expected moduleEntity for module ${moduleId}` ) @@ -618,7 +618,7 @@ export const savedStepForms = ( action.type === 'CREATE_CONTAINER' ? action.payload.id : action.payload.duplicateLabwareId - assert( + console.assert( prevInitialDeckSetupStep, 'expected initial deck setup step to exist, could not handle CREATE_CONTAINER' ) @@ -944,7 +944,7 @@ export const savedStepForms = ( const { stepId } = action.payload if (stepId == null) { - assert( + console.assert( false, `savedStepForms got CHANGE_SAVED_STEP_FORM action without a stepId` ) @@ -1026,7 +1026,7 @@ export const savedStepForms = ( const defaults = getDefaultsForStepType(prevStepForm.stepType) if (!prevStepForm) { - assert(false, `expected stepForm for id ${stepId}`) + console.assert(false, `expected stepForm for id ${stepId}`) return acc } diff --git a/protocol-designer/src/step-forms/selectors/index.ts b/protocol-designer/src/step-forms/selectors/index.ts index 9cb09cfb2de..223e9cb7dd3 100644 --- a/protocol-designer/src/step-forms/selectors/index.ts +++ b/protocol-designer/src/step-forms/selectors/index.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import isEqual from 'lodash/isEqual' import mapValues from 'lodash/mapValues' import reduce from 'lodash/reduce' @@ -105,7 +105,7 @@ function _hydrateLabwareEntity( defsByURI: LabwareDefByDefURI ): LabwareEntity { const def = defsByURI[l.labwareDefURI] - assert( + console.assert( def, `could not hydrate labware ${labwareId}, missing def for URI ${l.labwareDefURI}` ) @@ -215,7 +215,7 @@ const _getInitialDeckSetup = ( moduleEntities: ModuleEntities, additionalEquipmentEntities: AdditionalEquipmentEntities ): InitialDeckSetup => { - assert( + console.assert( initialSetupStep && initialSetupStep.stepType === 'manualIntervention', 'expected initial deck setup step to be "manualIntervention" step' ) diff --git a/protocol-designer/src/step-forms/utils/index.ts b/protocol-designer/src/step-forms/utils/index.ts index 7f1baae8fdc..a2ccb21a993 100644 --- a/protocol-designer/src/step-forms/utils/index.ts +++ b/protocol-designer/src/step-forms/utils/index.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import reduce from 'lodash/reduce' import values from 'lodash/values' import find from 'lodash/find' @@ -54,15 +54,15 @@ export function getIdsInRange( ): T[] { const startIdx = orderedIds.findIndex(id => id === startId) const endIdx = orderedIds.findIndex(id => id === endId) - assert( + console.assert( startIdx !== -1, `start step "${String(startId)}" does not exist in orderedStepIds` ) - assert( + console.assert( endIdx !== -1, `end step "${String(endId)}" does not exist in orderedStepIds` ) - assert( + console.assert( endIdx >= startIdx, `expected end index to be greater than or equal to start index, got "${startIdx}", "${endIdx}"` ) @@ -76,7 +76,7 @@ export function getDeckItemIdInSlot( const idsForSourceSlot = Object.entries(itemIdToSlot) .filter(([id, labwareSlot]) => labwareSlot === slot) .map(([id, labwareSlot]) => id) - assert( + console.assert( idsForSourceSlot.length < 2, `multiple deck items in slot ${slot}, expected none or one` ) diff --git a/protocol-designer/src/steplist/formLevel/handleFormChange/dependentFieldsUpdateMoveLiquid.ts b/protocol-designer/src/steplist/formLevel/handleFormChange/dependentFieldsUpdateMoveLiquid.ts index 29730634925..385ab97b0ab 100644 --- a/protocol-designer/src/steplist/formLevel/handleFormChange/dependentFieldsUpdateMoveLiquid.ts +++ b/protocol-designer/src/steplist/formLevel/handleFormChange/dependentFieldsUpdateMoveLiquid.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import clamp from 'lodash/clamp' import pick from 'lodash/pick' import round from 'lodash/round' @@ -401,7 +401,7 @@ const clampDisposalVolume = ( ) if (maxDisposalVolume == null) { - assert( + console.assert( false, `clampDisposalVolume got null maxDisposalVolume for pipette, something weird happened` ) diff --git a/protocol-designer/src/steplist/formLevel/handleFormChange/utils.ts b/protocol-designer/src/steplist/formLevel/handleFormChange/utils.ts index be4c393775a..3efb4e006e8 100644 --- a/protocol-designer/src/steplist/formLevel/handleFormChange/utils.ts +++ b/protocol-designer/src/steplist/formLevel/handleFormChange/utils.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import round from 'lodash/round' import uniq from 'lodash/uniq' import { getWellSetForMultichannel, canPipetteUseLabware } from '../../../utils' @@ -64,7 +64,7 @@ export function getMaxDisposalVolumeForMultidispense( // calculate max disposal volume for given volume & pipette. Might be negative! const pipetteId = values?.pipette if (!values || !pipetteId) return null - assert( + console.assert( values.path === 'multiDispense', `getMaxDisposalVolumeForMultidispense expected multiDispense, got path ${values.path}` ) @@ -83,7 +83,7 @@ export function volumeInCapacityForMulti( rawForm: FormData, pipetteEntities: PipetteEntities ): boolean { - assert( + console.assert( rawForm.pipette in pipetteEntities, `volumeInCapacityForMulti expected pipette ${rawForm.pipette} to be in pipetteEntities` ) @@ -155,7 +155,7 @@ export function getDefaultWells(args: GetDefaultWellsArgs): string[] { if (isSingleWellLabware) { const well = labwareDef.ordering[0][0] - assert( + console.assert( well === 'A1', `sanity check: expected single-well labware ${labwareId} to have only the well 'A1'` ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/heaterShakerFormToArgs.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/heaterShakerFormToArgs.ts index c1e9e867949..8c7af6966a2 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/heaterShakerFormToArgs.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/heaterShakerFormToArgs.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { HeaterShakerArgs } from '@opentrons/step-generation' import type { HydratedHeaterShakerFormData } from '../../../form-types' @@ -13,13 +13,13 @@ export const heaterShakerFormToArgs = ( setShake, latchOpen, } = formData - assert( + console.assert( setHeaterShakerTemperature ? !Number.isNaN(targetHeaterShakerTemperature) : true, 'heaterShakerFormToArgs expected targetTemp to be a number when setTemp is true' ) - assert( + console.assert( setShake ? !Number.isNaN(targetSpeed) : true, 'heaterShakerFormToArgs expected targeShake to be a number when setShake is true' ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/magnetFormToArgs.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/magnetFormToArgs.ts index 498c713f1cd..f5e60d74163 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/magnetFormToArgs.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/magnetFormToArgs.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { EngageMagnetArgs, DisengageMagnetArgs, @@ -11,7 +11,7 @@ export const magnetFormToArgs = ( const { magnetAction, moduleId } = hydratedFormData // @ts-expect-error(sa, 2021-6-14): null check engageHeight const engageHeight = parseFloat(hydratedFormData.engageHeight) - assert( + console.assert( magnetAction === 'engage' ? !Number.isNaN(engageHeight) : true, 'magnetFormToArgs expected (hydrated) engageHeight to be non-NaN if magnetAction is "engage"' ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.ts index 1edccb7c59d..5b8c066112e 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { getWellsDepth } from '@opentrons/shared-data' import { DEFAULT_CHANGE_TIP_OPTION, @@ -46,7 +46,7 @@ export const mixFormToArgs = ( hydratedFormData.mix_mmFromBottom || DEFAULT_MM_FROM_BOTTOM_DISPENSE // It's radiobutton, so one should always be selected. // One changeTip option should always be selected. - assert( + console.assert( hydratedFormData.changeTip, 'mixFormToArgs expected non-falsey changeTip option' ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/moveLiquidFormToArgs.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/moveLiquidFormToArgs.ts index 62fde81b5cb..a8591e93d8c 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/moveLiquidFormToArgs.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/moveLiquidFormToArgs.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { getWellsDepth, LabwareDefinition2 } from '@opentrons/shared-data' import { DEST_WELL_BLOWOUT_DESTINATION } from '@opentrons/step-generation' import { @@ -62,7 +62,7 @@ type MoveLiquidStepArgs = ConsolidateArgs | DistributeArgs | TransferArgs | null export const moveLiquidFormToArgs = ( hydratedFormData: HydratedMoveLiquidFormData ): MoveLiquidStepArgs => { - assert( + console.assert( hydratedFormData.stepType === 'moveLiquid', `moveLiquidFormToArgs called with stepType ${hydratedFormData.stepType}, expected "moveLiquid"` ) @@ -203,11 +203,11 @@ export const moveLiquidFormToArgs = ( dropTipLocation, nozzles, } - assert( + console.assert( sourceWellsUnordered.length > 0, 'expected sourceWells to have length > 0' ) - assert( + console.assert( !( path === 'multiDispense' && blowoutLocation === DEST_WELL_BLOWOUT_DESTINATION @@ -219,7 +219,7 @@ export const moveLiquidFormToArgs = ( console.error('expected to have destWells.length > 0 but got none') } - assert( + console.assert( !(path === 'multiDispense' && destWells == null), 'cannot distribute when destWells is null' ) @@ -268,7 +268,7 @@ export const moveLiquidFormToArgs = ( } default: { - assert( + console.assert( false, `moveLiquidFormToArgs got unexpected "path" field value: ${path}` ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/temperatureFormToArgs.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/temperatureFormToArgs.ts index 5c8045e8c49..29fa4d592af 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/temperatureFormToArgs.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/temperatureFormToArgs.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { SetTemperatureArgs, DeactivateTemperatureArgs, @@ -13,7 +13,7 @@ export const temperatureFormToArgs = ( const setTemperature = hydratedFormData.setTemperature === 'true' // @ts-expect-error(sa, 2021-6-14): null check targetTemperature const targetTemperature = parseFloat(hydratedFormData.targetTemperature) - assert( + console.assert( setTemperature ? !Number.isNaN(targetTemperature) : true, 'temperatureFormToArgs expected (hydrated) targetTemperature to be a number when setTemperature is "true"' ) diff --git a/protocol-designer/src/steplist/formLevel/stepFormToArgs/test/moveLiquidFormToArgs.test.ts b/protocol-designer/src/steplist/formLevel/stepFormToArgs/test/moveLiquidFormToArgs.test.ts index f9d670570d4..2ab435e3149 100644 --- a/protocol-designer/src/steplist/formLevel/stepFormToArgs/test/moveLiquidFormToArgs.test.ts +++ b/protocol-designer/src/steplist/formLevel/stepFormToArgs/test/moveLiquidFormToArgs.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { getLabwareDefURI } from '@opentrons/shared-data' import { fixtureP10Single } from '@opentrons/shared-data/pipette/fixtures/name' diff --git a/protocol-designer/src/steplist/generateSubstepItem.ts b/protocol-designer/src/steplist/generateSubstepItem.ts index d0b0f192787..b95f72e26ca 100644 --- a/protocol-designer/src/steplist/generateSubstepItem.ts +++ b/protocol-designer/src/steplist/generateSubstepItem.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import cloneDeep from 'lodash/cloneDeep' import range from 'lodash/range' import mapValues from 'lodash/mapValues' @@ -255,7 +255,7 @@ function transferLikeSubsteps(args: { // TODO Ian 2018-04-06 use assert here if (!pipetteSpec) { - assert( + console.assert( false, `Pipette "${pipetteId}" does not exist, step ${stepId} can't determine channels` ) @@ -271,7 +271,7 @@ function transferLikeSubsteps(args: { ) if (!substepCommandCreator) { - assert(false, `transferLikeSubsteps could not make a command creator`) + console.assert(false, `transferLikeSubsteps could not make a command creator`) return null } diff --git a/protocol-designer/src/top-selectors/timelineFrames.ts b/protocol-designer/src/top-selectors/timelineFrames.ts index 511b5af699f..06e0b5e0bbf 100644 --- a/protocol-designer/src/top-selectors/timelineFrames.ts +++ b/protocol-designer/src/top-selectors/timelineFrames.ts @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import assert from 'assert' + import { selectors as fileDataSelectors } from '../file-data' import { selectors as stepFormSelectors } from '../step-forms' import { getActiveItem } from '../ui/steps/selectors' @@ -69,7 +69,7 @@ const _timelineFrameHelper = (beforeActiveItem: boolean) => ( } } - assert( + console.assert( timelineIdx !== -1, `timelineFrameForActiveItem got unhandled terminal id: "${activeItem.id}"` ) diff --git a/protocol-designer/src/ui/steps/actions/thunks/index.ts b/protocol-designer/src/ui/steps/actions/thunks/index.ts index a41fb5faa82..c147490307c 100644 --- a/protocol-designer/src/ui/steps/actions/thunks/index.ts +++ b/protocol-designer/src/ui/steps/actions/thunks/index.ts @@ -1,4 +1,4 @@ -import assert from 'assert' + import last from 'lodash/last' import { getUnsavedForm, @@ -167,7 +167,7 @@ export const saveStepForm: () => ThunkAction = () => ( // this check is only for Flow. At this point, unsavedForm should always be populated if (!unsavedForm) { - assert( + console.assert( false, 'Tried to saveStepForm with falsey unsavedForm. This should never be able to happen.' ) @@ -204,7 +204,7 @@ export const saveSetTempFormWithAddedPauseUntilTemp: () => ThunkAction = () // this check is only for Flow. At this point, unsavedForm should always be populated if (!unsavedSetTemperatureForm) { - assert( + console.assert( false, 'Tried to saveSetTempFormWithAddedPauseUntilTemp with falsey unsavedForm. This should never be able to happen.' ) @@ -215,7 +215,7 @@ export const saveSetTempFormWithAddedPauseUntilTemp: () => ThunkAction = () if (!isPristineSetTempForm) { // this check should happen upstream (before dispatching saveSetTempFormWithAddedPauseUntilTemp in the first place) - assert( + console.assert( false, `tried to saveSetTempFormWithAddedPauseUntilTemp but form ${id} is not a pristine set temp form` ) @@ -224,7 +224,7 @@ export const saveSetTempFormWithAddedPauseUntilTemp: () => ThunkAction = () const temperature = unsavedSetTemperatureForm?.targetTemperature - assert( + console.assert( temperature != null && temperature !== '', `tried to auto-add a pause until temp, but targetTemperature is missing: ${temperature}` ) @@ -268,7 +268,7 @@ export const saveSetTempFormWithAddedPauseUntilTemp: () => ThunkAction = () if (unsavedPauseForm != null) { dispatch(_saveStepForm(unsavedPauseForm)) } else { - assert(false, 'could not auto-save pause form, getUnsavedForm returned') + console.assert(false, 'could not auto-save pause form, getUnsavedForm returned') } } @@ -283,7 +283,7 @@ export const saveHeaterShakerFormWithAddedPauseUntilTemp: () => ThunkAction ) if (!unsavedHeaterShakerForm) { - assert( + console.assert( false, 'Tried to saveSetHeaterShakerTempFormWithAddedPauseUntilTemp with falsey unsavedForm. This should never be able to happen.' ) @@ -293,7 +293,7 @@ export const saveHeaterShakerFormWithAddedPauseUntilTemp: () => ThunkAction const { id } = unsavedHeaterShakerForm if (!isPristineSetHeaterShakerTempForm) { - assert( + console.assert( false, `tried to saveSetHeaterShakerTempFormWithAddedPauseUntilTemp but form ${id} is not a pristine set heater shaker temp form` ) @@ -302,7 +302,7 @@ export const saveHeaterShakerFormWithAddedPauseUntilTemp: () => ThunkAction const temperature = unsavedHeaterShakerForm?.targetHeaterShakerTemperature - assert( + console.assert( temperature != null && temperature !== '', `tried to auto-add a pause until temp, but targetHeaterShakerTemperature is missing: ${temperature}` ) @@ -341,6 +341,6 @@ export const saveHeaterShakerFormWithAddedPauseUntilTemp: () => ThunkAction if (unsavedPauseForm != null) { dispatch(_saveStepForm(unsavedPauseForm)) } else { - assert(false, 'could not auto-save pause form, getUnsavedForm returned') + console.assert(false, 'could not auto-save pause form, getUnsavedForm returned') } } diff --git a/protocol-designer/src/utils/labwareModuleCompatibility.ts b/protocol-designer/src/utils/labwareModuleCompatibility.ts index 0bb32a23e2b..57b6e3cc5bf 100644 --- a/protocol-designer/src/utils/labwareModuleCompatibility.ts +++ b/protocol-designer/src/utils/labwareModuleCompatibility.ts @@ -1,5 +1,5 @@ // PD-specific info about labware<>module compatibilty -import assert from 'assert' + import { MAGNETIC_MODULE_TYPE, TEMPERATURE_MODULE_TYPE, @@ -72,7 +72,7 @@ export const getLabwareIsCompatible = ( def: LabwareDefinition2, moduleType: ModuleType ): boolean => { - assert( + console.assert( moduleType in COMPATIBLE_LABWARE_ALLOWLIST_BY_MODULE_TYPE, `expected ${moduleType} in labware<>module compatibility allowlist` ) diff --git a/shared-data/js/helpers/index.ts b/shared-data/js/helpers/index.ts index f96f38ff2a5..5cddd22336e 100644 --- a/shared-data/js/helpers/index.ts +++ b/shared-data/js/helpers/index.ts @@ -1,4 +1,3 @@ -import assert from 'assert' import uniq from 'lodash/uniq' import { OPENTRONS_LABWARE_NAMESPACE } from '../constants' @@ -82,7 +81,7 @@ export const getLabwareDisplayName = ( } export const getTiprackVolume = (labwareDef: LabwareDefinition2): number => { - assert( + console.assert( labwareDef.parameters.isTiprack, `getTiprackVolume expected a tiprack labware ${getLabwareDefURI( labwareDef @@ -90,7 +89,7 @@ export const getTiprackVolume = (labwareDef: LabwareDefinition2): number => { ) // NOTE: Ian 2019-04-16 assuming all tips are the same volume across the rack const volume = labwareDef.wells.A1.totalLiquidVolume - assert( + console.assert( volume >= 0, `getTiprackVolume expected tip volume to be at least 0, got ${volume}` )