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

fix(app, shared-data): app crashes when using python apiLevel<2.16 with fixed trash #16451

Open
wants to merge 7 commits into
base: edge
Choose a base branch
from

Conversation

TamarZanzouri
Copy link
Contributor

@TamarZanzouri TamarZanzouri commented Oct 9, 2024

Overview

closes EXEC-759 - fix render deck map when trash is fixed (python api version < 2.16).

Test Plan and Hands on Testing

upload the following protocol without labware on the deck:

from opentrons import protocol_api, types

metadata = {
    "apiLevel": "2.15",
}

requirements = {
    "robotType": "OT-3"
}

def run(ctx: protocol_api.ProtocolContext) -> None:
    tip_rack_50 = ctx.load_labware("opentrons_flex_96_filtertiprack_50ul", 4)
    ctx.move_labware(labware=tip_rack_50, new_location=5, use_gripper=True)
  1. enter ER
  2. select manually remove labware
  3. make sure that after the count down the app is not crashing.
  4. make sure deck map is rendering.

tested deck map locally - works as expected.

Changelog

fixed but when using deck map with fixed trash with python protocols bellow 2.16.
added shared-data method to get fixed trash definition

Review requests

changes make sense? did I forget anyhing?

Risk assessment

low

@TamarZanzouri TamarZanzouri requested a review from a team as a code owner October 9, 2024 21:07
@TamarZanzouri TamarZanzouri requested review from brenthagen, sfoster1 and mjhuff and removed request for a team and brenthagen October 9, 2024 21:07
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

some code style comments that rise into sort of alarm levels when I note that the code that was there before your PR is doing a full command list scan every time through the reduce...

const labwareDefinitionsByUri = getLoadedLabwareDefinitionsByUri(
protocolAnalysis.commands
)
let labwareDefinitionsByUri: LabwareDefinitionsByUri
Copy link
Member

Choose a reason for hiding this comment

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

Wait does this mean we're doing a full command array scan for every reduce callback here? Can we instead do something like

  • hoist const protocolLabwareDefinitionsByUri = getLoadedLabwareDefinitionsByUri(...) to like line 261, outside of this reduce
  • factor this logic into a function like
const getLabwareDefinition = (uri: string) => { 
   if (lw.id === 'fixedTrash) {
      return getFixedTrashLabwareDefinitionsByUri(lw.definitionUri)[lw.definitionUri]
   } else {
      return protocolLabwareDefinitionsByUri[lw.definitionUri]
   }

which preserves constness, and then call that function in the reduce?

import type { LabwareDefinitionsByUri } from './getLoadedLabwareDefinitionsByUri'
import fixedTrashUncasted from '../../labware/definitions/2/opentrons_1_trash_3200ml_fixed/1.json'

export function getFixedTrashLabwareDefinitionsByUri(
Copy link
Member

Choose a reason for hiding this comment

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

if we do my comment above, this doesn't have to work the same way as getLoadedLabwareDefinitionsByUri() and can just return the definition directly instead of a one-element computed-key object

Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Yeah, the major issue is definitely my fault here. I think Seth covered everything, we need to hoist out the command scanning util. My one comment shouldn't apply if you use his recommendation for how to refactor getFixedTrashLabwareDefinitionsByUri. Thanks for doing all this!

Comment on lines +266 to +269
if (lw.id === 'fixedTrash') {
labwareDefinitionsByUri = getFixedTrashLabwareDefinitionsByUri(
lw.definitionUri
)
Copy link
Contributor

@mjhuff mjhuff Oct 9, 2024

Choose a reason for hiding this comment

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

Seth's approach should solve this, but if we do end up needing some sort association of the lw to the actual definitionUri, we should validate that the lw is a fixedTrash within the shared-data util itself.

Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

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

Actually, we do this same nested iterative check on L208, so if you could move that outside of the reduce using the same aforementioned logic, that would be great!

EDIT: To clarify, it would probably be best to invoke this only once outside of BOTH getRunCurrentModulesInfo and getRunCurrentLabwareInfo and pass a memoized value of the labware defs to those functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants