Skip to content

Commit d6b5964

Browse files
committed
feat(protocol-designer): introduce LiquidEntities and update ingredients JSON key to match
closes AUTH-1382
1 parent 4f3acfc commit d6b5964

File tree

16 files changed

+85
-105
lines changed

16 files changed

+85
-105
lines changed

app/src/organisms/ODD/QuickTransferFlow/utils/generateQuickTransferArgs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ function getInvariantContextAndRobotState(
220220
moduleEntities: {},
221221
pipetteEntities,
222222
additionalEquipmentEntities,
223+
liquidEntities: {},
223224
config: { OT_PD_DISABLE_MODULE_RESTRICTIONS: false },
224225
}
225226
const moduleLocations = {}

protocol-designer/fixtures/protocol/8/doItAllV3MigratedToV8.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
},
3434
"ingredients": {
3535
"0": {
36-
"name": "Water",
36+
"displayName": "Water",
37+
"displayColor": "#b925ff",
3738
"description": null,
38-
"serialize": false,
39+
"pythonName": "liquid_0",
3940
"liquidGroupId": "0"
4041
}
4142
},

protocol-designer/fixtures/protocol/8/doItAllV4MigratedToV8.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
},
3434
"ingredients": {
3535
"0": {
36-
"name": "Water",
36+
"displayName": "Water",
37+
"displayColor": "#b925ff",
3738
"description": null,
38-
"serialize": false,
39+
"pythonName": "liquid_0",
3940
"liquidGroupId": "0"
4041
}
4142
},

protocol-designer/fixtures/protocol/8/doItAllV7MigratedToV8.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@
3636
},
3737
"ingredients": {
3838
"0": {
39-
"name": "Water",
39+
"displayName": "Water",
4040
"displayColor": "#b925ff",
4141
"description": null,
42-
"serialize": false,
42+
"pythonName": "liquid_0",
4343
"liquidGroupId": "0"
4444
},
4545
"1": {
46-
"name": "Samples",
46+
"displayName": "Samples",
4747
"displayColor": "#ffd600",
4848
"description": null,
49-
"serialize": false,
49+
"pythonName": "liquid_1",
5050
"liquidGroupId": "1"
5151
}
5252
},

protocol-designer/fixtures/protocol/8/doItAllV8.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
},
3434
"ingredients": {
3535
"0": {
36-
"name": "h20",
36+
"displayName": "h20",
3737
"displayColor": "#b925ff",
3838
"description": null,
39-
"serialize": false,
39+
"pythonName": "liquid_0",
4040
"liquidGroupId": "0"
4141
},
4242
"1": {
43-
"name": "sample",
43+
"displayName": "sample",
4444
"displayColor": "#ffd600",
4545
"description": null,
46-
"serialize": false,
47-
"liquidGroupId": "1"
46+
"liquidGroupId": "1",
47+
"pythonName": "liquid_1"
4848
}
4949
},
5050
"ingredLocations": {

protocol-designer/fixtures/protocol/8/example_1_1_0MigratedToV8.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@
3636
},
3737
"ingredients": {
3838
"0": {
39-
"name": "samples",
39+
"displayName": "samples",
4040
"description": null,
41-
"serialize": false,
41+
"displayColor": "#b925ff",
42+
"pythonName": "liquid_0",
4243
"liquidGroupId": "0"
4344
},
4445
"1": {
45-
"name": "dna",
46+
"displayName": "dna",
4647
"description": null,
47-
"serialize": false,
48+
"pythonName": "liquid_1",
49+
"displayColor": "#ffd600",
4850
"liquidGroupId": "1"
4951
}
5052
},

protocol-designer/fixtures/protocol/8/thermocyclerOnOt2V7MigratedToV8.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
},
3434
"ingredients": {
3535
"0": {
36-
"name": "123",
36+
"displayName": "123",
3737
"displayColor": "#b925ff",
3838
"description": null,
39-
"serialize": false,
39+
"pythonName": "liquid_0",
4040
"liquidGroupId": "0"
4141
}
4242
},

protocol-designer/src/labware-ingred/__tests__/ingredients.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it, expect, vi } from 'vitest'
22
import { ingredients, ingredLocations } from '../reducers'
3+
import type { LiquidEntities } from '@opentrons/step-generation'
34
vi.mock('../../labware-defs/utils')
45

56
describe('DUPLICATE_LABWARE action', () => {
@@ -13,24 +14,20 @@ describe('DUPLICATE_LABWARE action', () => {
1314
},
1415
}
1516

16-
const prevIngredState = {
17+
const prevIngredState: LiquidEntities = {
1718
ingred3: {
18-
name: 'Buffer',
19-
wellDetailsByLocation: null,
20-
concentration: '50 mol/ng',
19+
displayName: 'Buffer',
2120
description: '',
22-
liquidClass: null,
2321
displayColor: '#b925ff',
24-
serialize: false,
22+
liquidGroupId: '0',
23+
pythonName: 'python_0',
2524
},
2625
ingred4: {
27-
name: 'Other Ingred',
28-
wellDetailsByLocation: null,
29-
concentration: '100%',
26+
displayName: 'Other Ingred',
3027
description: '',
31-
liquidClass: null,
3228
displayColor: '#ffd600',
33-
serialize: false,
29+
liquidGroupId: '1',
30+
pythonName: 'liquid_1',
3431
},
3532
}
3633

protocol-designer/src/labware-ingred/__tests__/selectors.test.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

protocol-designer/src/load-file/migration/8_5_0.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import floor from 'lodash/floor'
2+
import { swatchColors } from '../../organisms/DefineLiquidsModal/swatchColors'
23
import type {
34
LabwareDefinition2,
45
LoadLabwareCreateCommand,
56
ProtocolFile,
67
} from '@opentrons/shared-data'
8+
import type { LiquidEntities } from '@opentrons/step-generation'
9+
import type { DesignerApplicationDataV8 } from '../../file-data/selectors'
710
import type { DesignerApplicationData } from './utils/getLoadLiquidCommands'
811

912
const getMigratedPositionFromTop = (
@@ -48,15 +51,31 @@ const getMigratedPositionFromTop = (
4851

4952
export const migrateFile = (
5053
appData: ProtocolFile<DesignerApplicationData>
51-
): ProtocolFile<DesignerApplicationData> => {
52-
const { designerApplication, commands, labwareDefinitions } = appData
54+
): ProtocolFile<DesignerApplicationDataV8> => {
55+
const { designerApplication, commands, labwareDefinitions, liquids } = appData
5356

5457
if (designerApplication == null || designerApplication?.data == null) {
5558
throw Error('The designerApplication key in your file is corrupt.')
5659
}
5760
const savedStepForms = designerApplication.data
5861
?.savedStepForms as DesignerApplicationData['savedStepForms']
5962

63+
const ingredients = designerApplication.data.ingredients
64+
65+
const migratedIngredients: LiquidEntities = Object.entries(
66+
ingredients
67+
).reduce<LiquidEntities>((acc, [id, ingredient]) => {
68+
acc[id] = {
69+
displayName: ingredient.name ?? '',
70+
liquidClass: ingredient.liquidClass,
71+
description: ingredient.description ?? null,
72+
liquidGroupId: id,
73+
pythonName: `liquid_${id}`,
74+
displayColor: liquids[id].displayColor ?? swatchColors(id),
75+
}
76+
return acc
77+
}, {})
78+
6079
const loadLabwareCommands = commands.filter(
6180
(command): command is LoadLabwareCreateCommand =>
6281
command.commandType === 'loadLabware'
@@ -153,6 +172,7 @@ export const migrateFile = (
153172
...designerApplication,
154173
data: {
155174
...designerApplication.data,
175+
ingredients: migratedIngredients,
156176
savedStepForms: {
157177
...designerApplication.data.savedStepForms,
158178
...savedStepsWithUpdatedMoveLiquidFields,

0 commit comments

Comments
 (0)