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

refactor(app): currentOffsetModal only displays latest offsets #11913

Merged
merged 9 commits into from
Jan 10, 2023

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented Dec 20, 2022

closes RLAB-200

Overview

CurrentOffsetModal used to display all offsets even duplicates and labware offsets where the vector values are all 0. This PR creates a util getLatestCurrentOffsets that filters out the old offsets and the offsets that are 0. Additionally, this PR wires up the LPC cta in CurrentOffsetModal as well as keeping the disabled reason the same as in the main LPC CTA button.

Changelog

  • create getLatestCurrentOffsets and test
  • add the new util to CurrentOffsetsModal
  • create the CurrentOffsetModal test
  • create useLPCDisabledReason hook that is used in LaunchLabwarePositionCheck and CurrentOffsetsModal, create test for the hook

Review requests

go through LPC and add some offsets - go through it a few times, the CurrentOffsetModal should display only the latest offsets that were created. if there is a reason for the LPC CTA to be disabled, it should also be reflected in the modal

Risk assessment

low

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #11913 (982a108) into edge (c50e145) will decrease coverage by 0.19%.
The diff coverage is 92.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #11913      +/-   ##
==========================================
- Coverage   74.17%   73.97%   -0.20%     
==========================================
  Files        2164     2186      +22     
  Lines       59753    60727     +974     
  Branches     6265     6526     +261     
==========================================
+ Hits        44323    44925     +602     
- Misses      13953    14271     +318     
- Partials     1477     1531      +54     
Flag Coverage Δ
app 72.34% <92.72%> (-0.85%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...colRun/SetupLabware/LaunchLabwarePositionCheck.tsx 63.33% <66.66%> (-20.60%) ⬇️
...c/organisms/Devices/hooks/useLPCDisabledReason.tsx 94.11% <94.11%> (ø)
...s/ProtocolRun/SetupLabware/CurrentOffsetsModal.tsx 85.71% <100.00%> (+63.49%) ⬆️
...rganisms/Devices/ProtocolRun/SetupLabware/utils.ts 88.88% <100.00%> (+4.27%) ⬆️
...librationDetails/PipetteOffsetCalibrationItems.tsx 70.37% <0.00%> (-6.11%) ⬇️
...rc/organisms/Devices/RobotOverviewOverflowMenu.tsx 87.09% <0.00%> (-3.82%) ⬇️
...ibration/RobotSettingsPipetteOffsetCalibration.tsx 88.88% <0.00%> (-1.12%) ⬇️
app/src/redux/buildroot/selectors.ts 81.48% <0.00%> (-1.06%) ⬇️
...ngsCalibration/CalibrationDetails/OverflowMenu.tsx 74.56% <0.00%> (-0.81%) ⬇️
app/src/atoms/Tooltip/index.tsx 100.00% <0.00%> (ø)
... and 33 more

@jerader jerader force-pushed the app_filter-out-duplicates-current-offset-modal branch from 9ee5ed3 to 2d58aa1 Compare December 20, 2022 20:03
@jerader jerader marked this pull request as ready for review December 20, 2022 20:03
@jerader jerader requested a review from a team as a code owner December 20, 2022 20:03
@jerader jerader requested review from b-cooper, brenthagen, koji and a team and removed request for a team December 20, 2022 20:03
export function getLatestCurrentOffsets(
currentOffsets: LabwareOffset[]
): LabwareOffset[] {
const reverseCurrentOffsets = [...currentOffsets].reverse()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we reversing the array here? We shouldn't be relying on the inherent order of the offsets that we get back from the robot.

const latestCurrentOffsets = reverseCurrentOffsets.filter(
(currentOffset, index) =>
currentOffset.location.slotName === uniqueSlots[index] &&
!(
Copy link
Contributor

Choose a reason for hiding this comment

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

we've use isEqual(currentOffset.vector, IDENTITY_VECTOR) else for this comparison

Copy link
Member

@shlokamin shlokamin left a comment

Choose a reason for hiding this comment

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

code lgtm, will test on a robot in a sec

@@ -82,5 +82,6 @@
"labware_position_check_description": "<block>Labware Position Check is a guided workflow that checks every labware on the deck for an added degree of precision in your protocol.</block><block>Labware Position Check first checks tip racks, and then checks all other labware used in your protocol.</block>",
"all_modules_and_labware_from_protocol": "All modules and labware used in the protocol",
"module_in_slot": "{{module}} in {{slot}}",
"run_labware_position_check": "run labware position check"
"run_labware_position_check": "run labware position check",
"get_labware_offset_data": "Get Labware Offset Data"
Copy link
Member

Choose a reason for hiding this comment

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

not introduced by this PR, and probably warrants a bigger discussion with the whole app & ui team, but we probably shouldn't be having any sort of formatting (like capitalization) being done inside of these i18n files. i think we should instead always have these json files have lower case text, and hoist the responsibility of any formatting to be done by the consuming component.

will make a note to self to bring this up when everyone is back

const latestCurrentOffsets = nonIdentityOffsets.reduce<LabwareOffset[]>(
(acc, offset) => {
const previousMatchIndex = acc.findIndex(
ao =>
Copy link
Member

Choose a reason for hiding this comment

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

nit, can we name ao something more descriptive? reduce's are sorta tough to read as is

@shlokamin
Copy link
Member

shlokamin commented Dec 21, 2022

uh so i'm not sure what is going on, but i can't run LPC at all using protocols generated from prod PD on a robot running with sw version v6.2.0.

this line in depricatedLabware.ts is the culprit, it resolves to undefined:

const labwareDef = labwareDefinitions[currentLabware.definitionUri]

the protocol's labware key does not have a definitionUri field (it has a definitionId field), but the line above is looking for one. should we be using getInitialLabwareLocation instead?

there was some change regarding definitionId vs definitionUri that happened recently right @smb2268?

Screen Shot 2022-12-21 at 5 38 34 PM

@smb2268
Copy link
Contributor

smb2268 commented Dec 21, 2022

the protocol's labware key does not have a definitionUri field (it has a definitionId field), but the line above is looking for one. should we be using getInitialLabwareLocation instead?

Yeah we removed the translation of definitionUri to definitionId that used to happen in the schemaV6Adapter so now we should always be able to check for the definitionUri on the labware key that comes back from protocol analysis. Is this looking directly at the protocol file instead of at the analysis?

When @b-cooper and I were pairing on resolving the conflicts between the schemaV6Adapter removal stuff and his new LPC changes, we decided not to invest the time to make sure the old LPC still worked since it won't ever be accessible in a release. So all of the deprecated LPC components may have errors

@shlokamin @jerader

@jerader
Copy link
Collaborator Author

jerader commented Dec 22, 2022

When @b-cooper and I were pairing on resolving the conflicts between the schemaV6Adapter removal stuff and his new LPC changes, we decided not to invest the time to make sure the old LPC still worked since it won't ever be accessible in a release. So all of the deprecated LPC components may have errors

I can test LPC with the ff turned on with my robot this morning, and if it works I am leaning towards leaving this as is since we will be removing the deprecated components in the q1 release. @shlokamin @smb2268

@jerader jerader force-pushed the app_filter-out-duplicates-current-offset-modal branch from 0d29c1c to 026ff49 Compare December 23, 2022 18:31
@jerader
Copy link
Collaborator Author

jerader commented Dec 23, 2022

After discussing with Shlok yesterday, it seems that we want to be able to get through LPC on a robot to test this out before merging. However, it does work properly on simulator & emulator.

When attempting to test on a robot that is up to date with edge, I ran into numerous null protection errors with regards to modules since my protocol didn't have any modules. Errors appeared in getCheckSteps, getPrepCommands and PrepareSpace. After fixing those errors and restarting my app and robot, my robot got into a weird state where every single protocol failed protocol analysis because they weren't valid jsons. After awhile of trying to fix it, I was unsuccessful. Due to this, i ran out of time and was unable to get through LPC. I will also document this in the ticket but please feel free to merge this in when I'm out.

@b-cooper b-cooper self-requested a review January 10, 2023 21:32
Copy link
Contributor

@b-cooper b-cooper left a comment

Choose a reason for hiding this comment

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

@b-cooper b-cooper merged commit f2fcb0d into edge Jan 10, 2023
@b-cooper b-cooper deleted the app_filter-out-duplicates-current-offset-modal branch January 10, 2023 21:34
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.

None yet

4 participants