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(protocol-designer,shared-data): add description to liquid classes #17602

Open
wants to merge 6 commits into
base: edge
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions api/tests/opentrons/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ def minimal_liquid_class_def1() -> LiquidClassSchemaV1:
return LiquidClassSchemaV1(
liquidClassName="water1",
displayName="water 1",
description="some water",
schemaVersion=1,
namespace="test-fixture-1",
byPipette=[],
Expand All @@ -806,6 +807,7 @@ def minimal_liquid_class_def2() -> LiquidClassSchemaV1:
return LiquidClassSchemaV1(
liquidClassName="water2",
displayName="water 2",
description="some water",
schemaVersion=1,
namespace="test-fixture-2",
byPipette=[
Expand Down Expand Up @@ -879,6 +881,7 @@ def maximal_liquid_class_def() -> LiquidClassSchemaV1:
return LiquidClassSchemaV1(
liquidClassName="test_water",
displayName="Test Water",
description="some water",
schemaVersion=1,
namespace="opentrons",
byPipette=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_liquid_class_creation_and_property_fetching(
water = simulated_protocol_context.define_liquid_class("water")

assert water.name == "water"
assert water.display_name == "Water"
assert water.display_name == "Aqueous"

# TODO (spp, 2024-10-17): update this to fetch pipette load name from instrument context
assert (
Expand Down
2 changes: 2 additions & 0 deletions protocol-designer/src/assets/localization/en/liquids.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"delete_liquid": "Delete liquid",
"description": "Description",
"display_color": "Color",
"dont_use_liquid_class": "Don't use a liquid class",
"liquid_required": "Liquid required",
"liquid_volume": "Liquid volume by well",
"liquid_volume_nonzero": "Liquid volume must be larger than zero",
Expand All @@ -18,6 +19,7 @@
"title": "Liquid class",
"tooltip": "Applies predefined pipetting settings to transfer and mix steps using this liquid"
},
"liquid_class_name_description": "{{displayName}} ({{description}})",
"liquids_added": "Liquids added",
"liquids": "Liquids",
"microliters": "µL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
"distribute": "<text>Distributing</text><tag/><text>from</text><semiBoldText>{{sourceWells}} of {{source}}</semiBoldText><text>to</text><semiBoldText>{{destinationWells}} of {{destination}}</semiBoldText>",
"transfer": "<text>Transferring</text><tag/><text>from</text><semiBoldText>{{sourceWells}} of {{source}}</semiBoldText><text>to</text><semiBoldText>{{destinationWells}} of {{destination}}</semiBoldText>",
"consolidate_disposal": "<text>Consolidating</text><tag/><text>from</text><semiBoldText>{{sourceWells}} of {{source}}</semiBoldText><text>to</text><semiBoldText>{{destination}}</semiBoldText>",
"transfer_disposal": "<text>Transferring</text><tag/><text>from</text><semiBoldText>{{sourceWells}} of {{source}}</semiBoldText><text>to</text><semiBoldText>{{destination}}</semiBoldText>"
"transfer_disposal": "<text>Transferring</text><tag/><text>from</text><semiBoldText>{{sourceWells}} of {{source}}</semiBoldText><text>to</text><semiBoldText>{{destination}}</semiBoldText>",
"substeps": {
"multi": "<text>Multi</text><label1/><tag/><label2/>"
}
},
"multi_dispense_options": "Disposal volume",
"multiAspirate": "Consolidate path",
Expand Down
25 changes: 19 additions & 6 deletions protocol-designer/src/organisms/DefineLiquidsModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,25 @@
}

const liquidClassOptions = [
{ name: 'Choose an option', value: '' },
...Object.entries(liquidClassDefs).map(
([liquidClassDefName, { displayName }]) => {
return { name: displayName, value: liquidClassDefName }
}
),
{ name: t('liquids:dont_use_liquid_class'), value: '' },
...Object.entries(liquidClassDefs)
.sort(([_0, a], [_1, b]) => {
if (a.displayName < b.displayName) {
return -1
} else if (a.displayName > b.displayName) {
return 1
}
return 0
})
.map(([liquidClassDefName, { displayName, description }]) => {
return {
value: liquidClassDefName,
name: t('liquids:liquid_class_name_description', {
displayName,
description,
}),
}
}),

Check warning on line 156 in protocol-designer/src/organisms/DefineLiquidsModal/index.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/organisms/DefineLiquidsModal/index.tsx#L138-L156

Added lines #L138 - L156 were not covered by tests
]

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
options={pipetteOptions}
value={value ? String(value) : null}
title={t('pipette')}
width="100%"

Check warning on line 17 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/PipetteField.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/PipetteFields/PipetteField.tsx#L17

Added line #L17 was not covered by tests
/>
)
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import {
ALIGN_CENTER,
DIRECTION_COLUMN,
DeckInfoLabel,
Flex,
JUSTIFY_SPACE_BETWEEN,
ListButton,
NO_WRAP,
SPACING,
StyledText,
Tag,
WRAP,
} from '@opentrons/components'
import { Substep } from './Substep'
import { formatVolume } from './utils'
Expand All @@ -18,6 +19,7 @@
StepItemSourceDestRow,
SubstepIdentifier,
} from '../../../../steplist'
import { values } from 'lodash'
Copy link
Contributor

Choose a reason for hiding this comment

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

can move this up


interface MultichannelSubstepProps {
trashName: AdditionalEquipmentName | null
Expand Down Expand Up @@ -57,6 +59,43 @@
firstChannelDest ? firstChannelDest.well ?? 'Trash' : ''
}:${lastChannelDest ? lastChannelDest.well : ''}`

interface MultiChannelSubstepButtonProps {
tagText: string
sources: JSX.Element | null
destinations: JSX.Element | null
}

function MultiChannelSubstepButton(
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think you can export this as a component?
if exporting doesn't take so much time, I'll recomend you do that.

props: MultiChannelSubstepButtonProps
): JSX.Element {
const { tagText, sources, destinations } = props
const { t } = useTranslation('protocol_steps')
return (
<Flex
gridGap={SPACING.spacing4}
alignItems={ALIGN_CENTER}
flexWrap={WRAP}

Check warning on line 77 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L68-L77

Added lines #L68 - L77 were not covered by tests
>
<Trans
t={t}
i18nKey="move_liquid.substeps.multi"
components={{
text: (
<StyledText
desktopStyle="bodyDefaultRegular"
style={{ whiteSpace: NO_WRAP }}

Check warning on line 86 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L79-L86

Added lines #L79 - L86 were not covered by tests
/>
),
tag: <Tag type="default" text={tagText} />,
label1: sources ?? <></>,
label2: destinations ?? <></>,
}}
values={values}

Check warning on line 93 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L89-L93

Added lines #L89 - L93 were not covered by tests
/>
</Flex>

Check warning on line 95 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L95

Added line #L95 was not covered by tests
)
}

Check warning on line 97 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L97

Added line #L97 was not covered by tests

return (
<Flex
flexDirection={DIRECTION_COLUMN}
Expand All @@ -70,36 +109,35 @@
}}
>
{/* TODO: need to update this to match designs! */}
<ListButton type="noActive" onClick={handleToggleCollapsed}>
<ListButton
type="noActive"
onClick={handleToggleCollapsed}
padding={SPACING.spacing16}

Check warning on line 115 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L112-L115

Added lines #L112 - L115 were not covered by tests
>
<Flex
flexDirection={DIRECTION_COLUMN}
gridGap={SPACING.spacing4}
width="100%"
>
<Flex
padding={SPACING.spacing12}
justifyContent={JUSTIFY_SPACE_BETWEEN}
width="100%"
alignItems={ALIGN_CENTER}
>
<StyledText desktopStyle="bodyDefaultRegular">Multi</StyledText>
{firstChannelSource != null ? (
<DeckInfoLabel deckLabel={sourceWellRange} />
) : null}
<Tag
text={`${formatVolume(rowGroup[0].volume)} ${t(
'units.microliter'
)}`}
type="default"
shrinkToContent
/>
{firstChannelDest != null ? (
<DeckInfoLabel deckLabel={destWellRange} />
) : null}
</Flex>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}>
{!collapsed &&
rowGroup.map((row, rowKey) => {
{/* replace below Flex with custom component */}
<MultiChannelSubstepButton
tagText={`${formatVolume(rowGroup[0].volume)} ${t(
'units.microliter'
)}`}
sources={
firstChannelSource != null ? (
<DeckInfoLabel deckLabel={sourceWellRange} />
) : null

Check warning on line 130 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L123-L130

Added lines #L123 - L130 were not covered by tests
}
destinations={
firstChannelDest != null ? (
<DeckInfoLabel deckLabel={destWellRange} />
) : null
}

Check warning on line 136 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L132-L136

Added lines #L132 - L136 were not covered by tests
/>
{!collapsed ? (
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}>
{rowGroup.map((row, rowKey) => {

Check warning on line 140 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L138-L140

Added lines #L138 - L140 were not covered by tests
return (
<Substep
trashName={trashName}
Expand All @@ -113,7 +151,8 @@
/>
)
})}
</Flex>
</Flex>
) : null}

Check warning on line 155 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/MultichannelSubstep.tsx#L154-L155

Added lines #L154 - L155 were not covered by tests
</Flex>
</ListButton>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import {
FLEX_MAX_CONTENT,
Flex,
Icon,
PrimaryButton,
Expand Down Expand Up @@ -59,7 +58,7 @@
substeps.substepType === THERMOCYCLER_PROFILE ? (
<Toolbox
height="calc(100vh - 6rem)"
width={FLEX_MAX_CONTENT}
width="21.875rem"

Check warning on line 61 in protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/SubStepsToolbox.tsx

View check run for this annotation

Codecov / codecov/patch

protocol-designer/src/pages/Designer/ProtocolSteps/Timeline/SubStepsToolbox.tsx#L61

Added line #L61 was not covered by tests
closeButton={<Icon size="2rem" name="close" />}
onCloseClick={handleClose}
confirmButton={
Expand Down
6 changes: 5 additions & 1 deletion shared-data/js/liquidClasses.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import ethanol80V1Uncasted from '../liquid-class/definitions/1/ethanol_80.json'
import glycerol50V1Uncasted from '../liquid-class/definitions/1/glycerol_50.json'
import waterV1Uncasted from '../liquid-class/definitions/1/water.json'
import type { LiquidClass } from '.'

const ethanol80V1 = ethanol80V1Uncasted as LiquidClass
const glycerol50V1 = glycerol50V1Uncasted as LiquidClass
const waterV1 = waterV1Uncasted as LiquidClass

const defs = { waterV1 }
const defs = { ethanol80V1, glycerol50V1, waterV1 }

export const getAllLiquidClassDefs = (): Record<string, LiquidClass> => defs
1 change: 1 addition & 0 deletions shared-data/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ interface ByPipetteSetting {
export interface LiquidClass {
liquidClassName: string
displayName: string
description: string
schemaVersion: number
namespace: string
byPipette: ByPipetteSetting[]
Expand Down
3 changes: 2 additions & 1 deletion shared-data/liquid-class/definitions/1/ethanol_80.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"liquidClassName": "ethanol_80",
"displayName": "Ethanol-80",
"displayName": "Volatile",
"description": "80% ethanol",
"schemaVersion": 1,
"namespace": "opentrons",
"byPipette": [
Expand Down
3 changes: 2 additions & 1 deletion shared-data/liquid-class/definitions/1/glycerol_50.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"liquidClassName": "glycerol_50",
"displayName": "Glycerol-50",
"displayName": "Viscous",
"description": "50% glycerol",
"schemaVersion": 1,
"namespace": "opentrons",
"byPipette": [
Expand Down
3 changes: 2 additions & 1 deletion shared-data/liquid-class/definitions/1/water.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"liquidClassName": "water",
"displayName": "Water",
"displayName": "Aqueous",
"description": "Deionized water",
"schemaVersion": 1,
"namespace": "opentrons",
"byPipette": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"liquidClassName": "fixture_glycerol50",
"displayName": "Glycerol 50%",
"displayName": "Viscous",
"description": "50% glycerol",
"schemaVersion": 1,
"namespace": "opentrons",
"byPipette": [
Expand Down
5 changes: 5 additions & 0 deletions shared-data/liquid-class/schemas/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@
"type": "string",
"description": "User-readable name of the liquid class."
},
"description": {
"type": "string",
"description": "User-readable description of the liquid class"
},
"schemaVersion": {
"description": "Which schema version a liquid class is using",
"type": "number",
Expand Down Expand Up @@ -500,6 +504,7 @@
"required": [
"liquidClassName",
"displayName",
"description",
"schemaVersion",
"namespace",
"byPipette"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ class LiquidClassSchemaV1(BaseModel):
..., description="The name of the liquid (e.g., water, ethanol, serum)."
)
displayName: str = Field(..., description="User-readable name of the liquid class.")
description: str = Field(
..., description="User-readable description of the liquid class"
)
schemaVersion: Literal[1] = Field(
..., description="Which schema version a liquid class is using"
)
Expand Down
Loading