-
Notifications
You must be signed in to change notification settings - Fork 178
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
base: edge
Are you sure you want to change the base?
fix(app, shared-data): app crashes when using python apiLevel<2.16 with fixed trash #16451
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 thisreduce
- 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 const
ness, 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( |
There was a problem hiding this comment.
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
There was a problem hiding this 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!
if (lw.id === 'fixedTrash') { | ||
labwareDefinitionsByUri = getFixedTrashLabwareDefinitionsByUri( | ||
lw.definitionUri | ||
) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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:
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