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, api): calibration check middleware #6781

Merged

Conversation

Laura-Danielle
Copy link
Contributor

@Laura-Danielle Laura-Danielle commented Oct 15, 2020

Overview

This PR ports calibration check over to the new architecture style/design of the other calibration flows. It also changes the name from Robot Calibration Check -> Robot Calibration Health Check. Closes #6725 and closes #6710.

Changelog

  • Remove all pipette specific states
  • Add in an active tiprack and active pipette to the flow for tracking purposes
  • Add in states that allow you to "transition" from the first pipette to the second pipette
  • Remove all intermediate calibration threshold feedback screens for health check in the app
  • Add a return tip modal to transition from the first to second pip or to exit
  • Port cal check state machine and screens over to the new "simple state machine" and shared screens
  • Change robot calibration check -> calibration health check
  • Remove analytics call-sites (but keep the functions around for potential future use)
  • Hold the comparisons in a dataclass rather than a dictionary, and sort them by pipette rank
  • Fix all tests related to the above
  • Load tipracks in one at a time to slot 8

Limitations and/or TODOs

  1. The robot needs to send over the last error state along with a diagnosis (i.e. if comparing point one was the only one to fail send over pip offset re-do state)
  2. The error states need to be overhauled to match the new system
  3. We should load tipracks based on the pipette offset rather than pip attached (if applicable)
  4. We should check if all the flows have a tip upon exit rather than extraneously moving the robot to the tiprack
  5. We need to add in the ability to load a cal check block etc for tip length calibration checks
  6. The flow needs to be updated to match the new screens, so more states will probably need to be added in

Review requests

Please test on a robot, and let me know if there are other places I should throw TODOs in. I think at this point the PR should just be merged and all remaining work delegated to other tickets.

Risk assessment

High. This is completely changing how the calibration check session worked previously, although we are not releasing immediately, we should be weary of any new bugs that might get introduced.

@Laura-Danielle Laura-Danielle added app Affects the `app` project api Affects the `api` project WIP labels Oct 15, 2020
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.

awesome! 🔑

@@ -58,7 +65,13 @@ export function TipConfirmation(props: CalibrationPanelProps): React.Node {
sendCommands({ command: moveCommandString })
}

return (
const isBadTipPickUp =
Copy link
Contributor

Choose a reason for hiding this comment

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

We should move this cal check specific step/panel combination into it's own file in the CheckCalibration component directory. That way these generic panels don't have to serve every special case. This example is branching only on currentStep (within a check cal session), which is exactly what the parent component step/panel mapping does, it should just slot in there.


const ROBOT_CALIBRATION_CHECK_SUBTITLE = 'Robot calibration heatlh check'
const ROBOT_CALIBRATION_CHECK_SUBTITLE = 'Calibration heatlh check'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const ROBOT_CALIBRATION_CHECK_SUBTITLE = 'Calibration heatlh check'
const ROBOT_CALIBRATION_CHECK_SUBTITLE = 'Calibration health check'

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.

Lots of little change requests to keep in mind


if (moveCommandString) {
commands = [...commands, { command: moveCommandString }]
let commands = null
Copy link
Member

Choose a reason for hiding this comment

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

does the stuff in 190:196 only apply to isHealthCheck === true? if so consider moving it into the if block on 185:187. Also consider making this a const-binding using an anonymous function or a logical expression like a ternary, eg

const commands = isHealthCheck  
    ?( (finalCommand && activePipette?.rank
          ? ... 
           : ...)
    : ...)

@@ -26,9 +26,9 @@ import { CalibrationLabwareRender } from './CalibrationLabwareRender'
import styles from './styles.css'

const DECK_SETUP_WITH_BLOCK_PROMPT =
'Place full tip rack and Calibration Block on the deck within their designated slots as illustrated below.'
'Place full tip rack(s) and Calibration Block on the deck within their designated slots as illustrated below.'
Copy link
Member

Choose a reason for hiding this comment

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

it's a little thing, but in all flows except cal check this will never have multiple tip racks. consider either making separate values or making this a function that accepts the number of tipracks or something.

{ command: Sessions.sharedCalCommands.MOVE_TO_POINT_ONE }
)
let continueCommands
if (sessionType === Sessions.SESSION_TYPE_CALIBRATION_HEALTH_CHECK) {
Copy link
Member

Choose a reason for hiding this comment

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

Consider using const-binding here with a ternary or something.

@@ -16,4 +18,8 @@ export type CalibrationPanelProps = {|
sessionType: SessionType,
calBlock?: CalibrationLabware | null,
shouldPerformTipLength?: boolean | null,
checkBothPipettes?: boolean | null,
Copy link
Member

Choose a reason for hiding this comment

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

This is growing a whole lot of optional attributes. While we don't have to do it now, we should at the very least drop a todo to refactor this into a union type discriminated on the session type.

const comparison = comparisonsByStep[step]
if (comparison && comparison.exceedsThreshold) {
return comparison
].reduce((acc, step): CalibrationHealthCheckComparison | null => {
Copy link
Member

Choose a reason for hiding this comment

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

We needed this last-failed logic in the old system because of the overlapping of the calibration components; I don't think we need it anymore. Honestly since we're already going to have the marked-bad logic on the server side, it might be worth having the server just tell us which calibrations are a problem, and generating the troubleshooting screen based on that. In the interim, I think we definitely don't need this logic here.

@@ -20,7 +20,8 @@ class SessionCreateParams(BaseModel):
)
tipRackDefinition: Optional[dict] = Field(
None,
description='The full labware definition of the tip rack to calibrate.'
description='The full tiprack definition(s)'
Copy link
Member

Choose a reason for hiding this comment

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

this is definitely set up to be a single tip rack definition, if we want it to be possibly-multiple we should probably make the type List[dict] and change the session creators

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change the description back. Basically was having a lot of issues w/ pydantic models -- I wanted to have an optional create param for check calibration but it was mixing up deck cal w/ check cal when I didn't specify the tipracks I wanted to use. Then I thought about adding it to this model, but realized it just wasn't worth it at this point.

@@ -120,6 +121,10 @@ def __init__(self,
def hardware(self) -> ThreadManager:
return self._hardware

@property
Copy link
Member

Choose a reason for hiding this comment

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

good change but does it belong in this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change before your other PR that was put up. I'm going to be rebasing anyways so I'll probably just remove this to make it easier.

@@ -80,7 +80,8 @@ async def delete_session_handler(
session_obj = get_session(manager=session_manager,
session_id=sessionId,
api_router=router)

log.info("delete was called! ")
Copy link
Member

Choose a reason for hiding this comment

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

remember to remove/lower level

@@ -80,7 +80,8 @@ async def delete_session_handler(
session_obj = get_session(manager=session_manager,
session_id=sessionId,
api_router=router)

log.info("delete was called! ")
log.info(f"session object {session_obj}")
Copy link
Member

Choose a reason for hiding this comment

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

remember to remove/lower level


@classmethod
async def create(cls,
configuration: SessionConfiguration,
instance_meta: SessionMetaData) -> BaseSession:
"""Create an instance"""
# (lc, 10-19-2020) For now, only pass in empty tipracks. We cannot
# have a session model with an optional tiprack for session
# create params right now because of the pydantic union problem.
Copy link
Member

Choose a reason for hiding this comment

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

rather than having it be optional, having it be a list that therefore may be empty is probably a good choice

@Laura-Danielle Laura-Danielle force-pushed the refactor_calibration_check_middleware branch from 8f225c6 to 91f20e5 Compare October 21, 2020 14:23
@Laura-Danielle Laura-Danielle changed the base branch from edge to chore_release-4.0.0-beta.0 October 21, 2020 14:23
@Laura-Danielle Laura-Danielle marked this pull request as ready for review October 21, 2020 14:24
@Laura-Danielle Laura-Danielle requested review from a team as code owners October 21, 2020 14:24
@codecov
Copy link

codecov bot commented Oct 21, 2020

Codecov Report

❗ No coverage uploaded for pull request base (chore_release-4.0.0-beta.0@297bf06). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                      Coverage Diff                      @@
##             chore_release-4.0.0-beta.0    #6781   +/-   ##
=============================================================
  Coverage                              ?   87.53%           
=============================================================
  Files                                 ?      101           
  Lines                                 ?     4411           
  Branches                              ?        0           
=============================================================
  Hits                                  ?     3861           
  Misses                                ?      550           
  Partials                              ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 297bf06...2ed0fde. Read the comment docs.

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.

Code all looks good to me, will test some

# off after
session_controls_lights =\
not configuration.hardware.get_lights()['rails']
# await configuration.hardware.cache_instruments()
Copy link
Member

Choose a reason for hiding this comment

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

🤨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops!

@Laura-Danielle Laura-Danielle force-pushed the refactor_calibration_check_middleware branch from fc44bcb to d958f33 Compare October 22, 2020 02:15
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.

lgtm!

@Laura-Danielle Laura-Danielle merged commit 25c9eb9 into chore_release-4.0.0-beta.0 Oct 22, 2020
@Laura-Danielle Laura-Danielle deleted the refactor_calibration_check_middleware branch October 22, 2020 13:41
sfoster1 added a commit that referenced this pull request Nov 2, 2020
When the user selects and saves the trash surface as their tip length
calibration target, send an event to intercom so that support can follow
up about fulfilling a calibration block.

This also brings back the intercom event epics and bindings removed in
 #6781, without the calibration check session end bindings.
sfoster1 added a commit that referenced this pull request Nov 2, 2020
When the user selects and saves the trash surface as their tip length
calibration target, send an event to intercom so that support can follow
up about fulfilling a calibration block.

This also brings back the intercom event epics and bindings removed in
 #6781, without the calibration check session end bindings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the `api` project app Affects the `app` project
Projects
None yet
4 participants