Skip to content

Commit

Permalink
Merge branch 'chore_release-7.0.0' into app_desktop-robot-update-new-…
Browse files Browse the repository at this point in the history
…flows
  • Loading branch information
mjhuff committed Sep 7, 2023
2 parents 872ac57 + 4822f86 commit 44a2b71
Show file tree
Hide file tree
Showing 84 changed files with 980 additions and 2,985 deletions.
10 changes: 5 additions & 5 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,18 +751,18 @@ def get_labware_gripper_offsets(
"""Get the labware's gripper offsets of the specified type."""
parsed_offsets = self.get_definition(labware_id).gripperOffsets
offset_key = slot_name.name if slot_name else "default"
return (
LabwareMovementOffsetData(

if parsed_offsets is None or offset_key not in parsed_offsets:
return None
else:
return LabwareMovementOffsetData(
pickUpOffset=cast(
LabwareOffsetVector, parsed_offsets[offset_key].pickUpOffset
),
dropOffset=cast(
LabwareOffsetVector, parsed_offsets[offset_key].dropOffset
),
)
if parsed_offsets
else None
)

def get_grip_force(self, labware_id: str) -> float:
"""Get the recommended grip force for gripping labware using gripper."""
Expand Down
45 changes: 45 additions & 0 deletions api/tests/opentrons/protocol_engine/state/test_labware_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
Parameters,
LabwareRole,
OverlapOffset as SharedDataOverlapOffset,
GripperOffsets,
OffsetVector,
)
from opentrons.protocols.models import LabwareDefinition
from opentrons.types import DeckSlotName, Point, MountType
Expand Down Expand Up @@ -1346,6 +1348,49 @@ def test_get_labware_gripper_offsets(
)


def test_get_labware_gripper_offsets_default_no_slots(
well_plate_def: LabwareDefinition,
adapter_plate_def: LabwareDefinition,
) -> None:
"""It should get the labware's gripper offsets with only a default gripper offset entry."""
subject = get_labware_view(
labware_by_id={
"labware-id": LoadedLabware(
id="labware-id",
loadName="labware-load-name",
location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
definitionUri="some-labware-uri",
offsetId=None,
displayName="Fancy Labware Name",
)
},
definitions_by_uri={
"some-labware-uri": LabwareDefinition.construct( # type: ignore[call-arg]
gripperOffsets={
"default": GripperOffsets(
pickUpOffset=OffsetVector(x=1, y=2, z=3),
dropOffset=OffsetVector(x=4, y=5, z=6),
)
}
),
},
)

assert (
subject.get_labware_gripper_offsets(
labware_id="labware-id", slot_name=DeckSlotName.SLOT_D1
)
is None
)

assert subject.get_labware_gripper_offsets(
labware_id="labware-id", slot_name=None
) == LabwareMovementOffsetData(
pickUpOffset=LabwareOffsetVector(x=1, y=2, z=3),
dropOffset=LabwareOffsetVector(x=4, y=5, z=6),
)


def test_get_grip_force(
flex_50uL_tiprack: LabwareDefinition,
reservoir_def: LabwareDefinition,
Expand Down
10 changes: 10 additions & 0 deletions app-shell-odd/src/config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ConfigV16,
ConfigV17,
ConfigV18,
ConfigV19,
} from '@opentrons/app/src/redux/config/types'

export const MOCK_CONFIG_V12: ConfigV12 = {
Expand Down Expand Up @@ -108,3 +109,12 @@ export const MOCK_CONFIG_V18: ConfigV18 = {
})(),
version: 18,
}

export const MOCK_CONFIG_V19: ConfigV19 = {
...MOCK_CONFIG_V18,
version: 19,
update: {
...MOCK_CONFIG_V18.update,
hasJustUpdated: false,
},
}
39 changes: 25 additions & 14 deletions app-shell-odd/src/config/__tests__/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,74 @@ import {
MOCK_CONFIG_V16,
MOCK_CONFIG_V17,
MOCK_CONFIG_V18,
MOCK_CONFIG_V19,
} from '../__fixtures__'
import { migrate } from '../migrate'

const NEWEST_VERSION = 19

describe('config migration', () => {
it('should migrate version 12 to latest', () => {
const v12Config = MOCK_CONFIG_V12
const result = migrate(v12Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should migrate version 13 to latest', () => {
const v13Config = MOCK_CONFIG_V13
const result = migrate(v13Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should migrate version 14 to latest', () => {
const v14Config = MOCK_CONFIG_V14
const result = migrate(v14Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should migrate version 15 to latest', () => {
const v15Config = MOCK_CONFIG_V15
const result = migrate(v15Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should migrate version 16 to latest', () => {
const v16Config = MOCK_CONFIG_V16
const result = migrate(v16Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should migrate version 17 to latest', () => {
const v17Config = MOCK_CONFIG_V17
const result = migrate(v17Config)

expect(result.version).toBe(18)
expect(result).toEqual(MOCK_CONFIG_V18)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should keep version 18', () => {
const v18Config = MOCK_CONFIG_V18
const result = migrate(v18Config)

expect(result.version).toBe(18)
expect(result).toEqual(v18Config)
expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(MOCK_CONFIG_V19)
})

it('should keep version 19', () => {
const v19Config = MOCK_CONFIG_V19
const result = migrate(v19Config)

expect(result.version).toBe(NEWEST_VERSION)
expect(result).toEqual(v19Config)
})
})
18 changes: 17 additions & 1 deletion app-shell-odd/src/config/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
ConfigV16,
ConfigV17,
ConfigV18,
ConfigV19,
} from '@opentrons/app/src/redux/config/types'
// format
// base config v12 defaults
Expand Down Expand Up @@ -143,20 +144,34 @@ const toVersion18 = (prevConfig: ConfigV17): ConfigV18 => {
}
}

const toVersion19 = (prevConfig: ConfigV18): ConfigV19 => {
const nextConfig = {
...prevConfig,
version: 19 as const,
update: {
...prevConfig.update,
hasJustUpdated: false,
},
}
return nextConfig
}

const MIGRATIONS: [
(prevConfig: ConfigV12) => ConfigV13,
(prevConfig: ConfigV13) => ConfigV14,
(prevConfig: ConfigV14) => ConfigV15,
(prevConfig: ConfigV15) => ConfigV16,
(prevConfig: ConfigV16) => ConfigV17,
(prevConfig: ConfigV17) => ConfigV18
(prevConfig: ConfigV17) => ConfigV18,
(prevConfig: ConfigV18) => ConfigV19
] = [
toVersion13,
toVersion14,
toVersion15,
toVersion16,
toVersion17,
toVersion18,
toVersion19,
]

export const DEFAULTS: Config = migrate(DEFAULTS_V12)
Expand All @@ -170,6 +185,7 @@ export function migrate(
| ConfigV16
| ConfigV17
| ConfigV18
| ConfigV19
): Config {
let result = prevConfig
// loop through the migrations, skipping any migrations that are unnecessary
Expand Down
4 changes: 2 additions & 2 deletions app-shell-odd/src/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
} from '@opentrons/discovery-client'

import type { Action, Dispatch } from './types'
import type { Config } from './config'
import type { ConfigV1 } from '@opentrons/app/src/redux/config/schema-types'

const log = createLogger('discovery')

Expand All @@ -42,7 +42,7 @@ interface DiscoveryStore {
services?: LegacyService[]
}

let config: Config['discovery']
let config: ConfigV1['discovery']
let store: Store<DiscoveryStore>
let client: DiscoveryClient

Expand Down
29 changes: 27 additions & 2 deletions app-shell/src/__tests__/update.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// app-shell self-update tests
import * as ElectronUpdater from 'electron-updater'
import { UPDATE_VALUE } from '@opentrons/app/src/redux/config'
import { registerUpdate } from '../update'
import * as Cfg from '../config'

Expand Down Expand Up @@ -67,20 +68,44 @@ describe('update', () => {
})

it('handles shell:DOWNLOAD_UPDATE', () => {
handleAction({ type: 'shell:DOWNLOAD_UPDATE', meta: { shell: true } })
handleAction({
type: 'shell:DOWNLOAD_UPDATE',
meta: { shell: true },
})

expect(autoUpdater.downloadUpdate).toHaveBeenCalledTimes(1)

const progress = {
percent: 20,
}

autoUpdater.emit('download-progress', progress)

expect(dispatch).toHaveBeenCalledWith({
type: 'shell:DOWNLOAD_PERCENTAGE',
payload: {
percent: 20,
},
})

autoUpdater.emit('update-downloaded', { version: '1.0.0' })

expect(dispatch).toHaveBeenCalledWith({
type: 'shell:DOWNLOAD_UPDATE_RESULT',
payload: {},
})
expect(dispatch).toHaveBeenCalledWith({
type: UPDATE_VALUE,
payload: { path: 'update.hasJustUpdated', value: true },
meta: { shell: true },
})
})

it('handles shell:DOWNLOAD_UPDATE with error', () => {
handleAction({ type: 'shell:DOWNLOAD_UPDATE', meta: { shell: true } })
handleAction({
type: 'shell:DOWNLOAD_UPDATE',
meta: { shell: true },
})
autoUpdater.emit('error', new Error('AH'))

expect(dispatch).toHaveBeenCalledWith({
Expand Down
10 changes: 10 additions & 0 deletions app-shell/src/config/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
ConfigV16,
ConfigV17,
ConfigV18,
ConfigV19,
} from '@opentrons/app/src/redux/config/types'

export const MOCK_CONFIG_V0: ConfigV0 = {
Expand Down Expand Up @@ -240,3 +241,12 @@ export const MOCK_CONFIG_V18: ConfigV18 = {
})(),
version: 18,
}

export const MOCK_CONFIG_V19: ConfigV19 = {
...MOCK_CONFIG_V18,
version: 19,
update: {
...MOCK_CONFIG_V18.update,
hasJustUpdated: false,
},
}
Loading

0 comments on commit 44a2b71

Please sign in to comment.