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

chore(refactor): Refactor and cleanup volumetric scripts #13071

Merged
merged 53 commits into from
Jul 25, 2023

Conversation

ryanthecoder
Copy link
Contributor

Overview

Test Plan

Changelog

Review requests

Risk assessment

@ryanthecoder ryanthecoder requested review from a team as code owners July 10, 2023 20:01
@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #13071 (21915e9) into edge (76eece6) will decrease coverage by 8.23%.
The diff coverage is n/a.

❗ Current head 21915e9 differs from pull request most recent head da2b26d. Consider uploading reports for the commit da2b26d to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #13071      +/-   ##
==========================================
- Coverage   72.11%   63.88%   -8.23%     
==========================================
  Files        1531     1616      +85     
  Lines       50773    27976   -22797     
  Branches     3144     7219    +4075     
==========================================
- Hits        36614    17873   -18741     
+ Misses      13650     8361    -5289     
- Partials      509     1742    +1233     
Flag Coverage Δ
api ?
app 71.37% <ø> (+27.50%) ⬆️
components 63.08% <ø> (-1.41%) ⬇️
g-code-testing ?
hardware ?
hardware-testing ?
labware-library 49.17% <ø> (-0.35%) ⬇️
notify-server ?
ot3-gravimetric-test ?
protocol-designer 47.29% <ø> (ø)
react-api-client 64.25% <ø> (ø)
robot-server ?
shared-data ?
step-generation 87.17% <ø> (ø)
system-server ?
update-server ?
usb-bridge ?

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

see 1580 files with indirect coverage changes

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.

This is looking really solid. I think we could make it a little better by splitting some massive triple for loops into functions, but really my most specific rec is: we should get replace print and input with a call to that ui module. It'll really help if we ever want to add fanciness there.

@@ -235,8 +229,9 @@ def run_photometric(
deck_version="2",
extra_labware=custom_defs,
)
union_cfg: Union[PhotometricConfig, GravimetricConfig]
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could factor this into like

def config_from_args(args: argparse.Namespace, context: Whatever_Ctx_is) -> Union[PhotometricConfig, GravimetricConfig]`

which means we wouldn't have to do the temporarily-unbound variable thing and could test it easily if we ever added tests

tips=get_tips(_ctx, pipette, all_channels=all_channels_same_time),
)

if args.photometric:
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 added an element to each config called kind: Literal['photometric'] and kind: Literal['gravimetric'] then you'd be able to have this be a discriminated union which means you could do if cfg.kind == 'photometric' and mypy would figure it out. You could also bind the run function into the config object.

labware_on_scale: Labware,
measure_height: float,
) -> Tuple[float, float]:
if not cfg.blank or cfg.inspect:
Copy link
Member

Choose a reason for hiding this comment

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

recommend factoring the body of each if/else into its own function to save an indent level

False,
measure_height=measure_height,
)
for volume in trials.keys():
actual_asp_list_all = []
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth getting these for loops to each be their own function

pipette.pick_up_tip(location)
# NOTE: the accuracy-adjust function gets set on the Pipette
# each time we pick-up a new tip.
if getattr(cfg, "increment", False):
Copy link
Member

Choose a reason for hiding this comment

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

does it need to be a getattr?


# NOTE: 8ch QC testing means testing 1 channel at a time,
# so we need to decrease the pick-up current to work with 1 tip.
if pipette.channels == 8 and not getattr(cfg, "increment", False):
Copy link
Member

Choose a reason for hiding this comment

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

does it need to be a getattr?

@ryanthecoder ryanthecoder force-pushed the refactor-and-clean-volumetric-scripts branch 3 times, most recently from 50dc526 to 9f5420f Compare July 11, 2023 20:06
@ryanthecoder ryanthecoder force-pushed the refactor-and-clean-volumetric-scripts branch from eb5b6f0 to 5c21325 Compare July 18, 2023 18:59
hwapi = get_sync_hw_api(ctx)
mnt = OT3Mount.LEFT if cfg.pipette_mount == "left" else OT3Mount.RIGHT
hwpipette: Pipette = hwapi.hardware_pipettes[mnt.to_mount()]
hwpipette.pick_up_configurations.current = 0.2
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 do something to call this out more, maybe pull its definition up to somewhere more visible in a followup PR

blank=blank,
inspect=cfg.inspect,
mix=cfg.mix,
stable=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

should be True I think

Copy link
Contributor

@andySigler andySigler left a comment

Choose a reason for hiding this comment

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

looks good other than the stable=True part 👍

@ryanthecoder ryanthecoder force-pushed the refactor-and-clean-volumetric-scripts branch from 2577b15 to 21915e9 Compare July 24, 2023 20:05
@ryanthecoder ryanthecoder merged commit 32cab97 into edge Jul 25, 2023
6 checks passed
ryanthecoder added a commit that referenced this pull request Jul 26, 2023
* Revert "Merge latest volumetric changes (#13100)"

This reverts commit 773b8a4.

* Revert "fix(hardware-testing): Remove tips using them for finding liquid height (#13064)"

This reverts commit cc0f509.

* Revert "support resupplying tipracks during a 96ch increment test run (#13065)"

This reverts commit 965f02d.

* Pull out all of the common functions between gravimetric and photometric

* move trial generation out of excecute

* combine the load pipette logic

* pull gantry speed out of the photometric config

* refactor out load tipracks

* remove unused method

* fix issues from rebasing

* fixups from rebase and formating

* refactor out trial building from the photometric script

* add additional test targets

* pull out the common elements of trials into a seperate dataclass

* break out even more common code

* break building pm report out of the run method

* break the run trials loop out of the run method

* format/lint

* break building test report out of the run method in gravimetric run method

* add the ui header to the build_report methods

* move all of the dye prep into the dye prep method

* improve LiquidTracker initialization

* move the homing to execute_trials

* refactor out common end script code

* refactor out common get_tips

* fixup things that broke during rebase

* fix the photometric test target

* remove evaporation measurement out of run for readablity

* break out load scale for readablity

* redo: Support resupplying tipracks during a 96ch increment tests

* redo: Remove tips using them for finding liquid height

* fix the tests

* replace all print statements with ui

* move the if-else out of the function to decrease the indent

* make a base class config

* fixup things that were lost in the rebase

* construct the trial directory correctly

* make sure 96 pipette doesn't collide during gravimetric tests

* gracefully handle when the scale is beyond max

* reimplement: Merge latest volumetric changes (#13100)

* add stable flag to the blank gravimetric trials

* Convert the default test volumes to the QC volumes

* add default number of trials and correct volumes to match calculator sheet

* make blank the default

* update makefile to test the correct args for each tip

* update increment test values

* make single channle QC test work with all tips in one run

* last few changes

* fixup typing error

* forgot a docstring for the linter

* support the enviornmental sensor in the volumetric tests

* make the asair prompt for port instead of auto finding

* fix the tests
caila-marashaj pushed a commit that referenced this pull request Jul 26, 2023
* Revert "Merge latest volumetric changes (#13100)"

This reverts commit 773b8a4.

* Revert "fix(hardware-testing): Remove tips using them for finding liquid height (#13064)"

This reverts commit cc0f509.

* Revert "support resupplying tipracks during a 96ch increment test run (#13065)"

This reverts commit 965f02d.

* Pull out all of the common functions between gravimetric and photometric

* move trial generation out of excecute

* combine the load pipette logic

* pull gantry speed out of the photometric config

* refactor out load tipracks

* remove unused method

* fix issues from rebasing

* fixups from rebase and formating

* refactor out trial building from the photometric script

* add additional test targets

* pull out the common elements of trials into a seperate dataclass

* break out even more common code

* break building pm report out of the run method

* break the run trials loop out of the run method

* format/lint

* break building test report out of the run method in gravimetric run method

* add the ui header to the build_report methods

* move all of the dye prep into the dye prep method

* improve LiquidTracker initialization

* move the homing to execute_trials

* refactor out common end script code

* refactor out common get_tips

* fixup things that broke during rebase

* fix the photometric test target

* remove evaporation measurement out of run for readablity

* break out load scale for readablity

* redo: Support resupplying tipracks during a 96ch increment tests

* redo: Remove tips using them for finding liquid height

* fix the tests

* replace all print statements with ui

* move the if-else out of the function to decrease the indent

* make a base class config

* fixup things that were lost in the rebase

* construct the trial directory correctly

* make sure 96 pipette doesn't collide during gravimetric tests

* gracefully handle when the scale is beyond max

* reimplement: Merge latest volumetric changes (#13100)

* add stable flag to the blank gravimetric trials

* Convert the default test volumes to the QC volumes

* add default number of trials and correct volumes to match calculator sheet

* make blank the default

* update makefile to test the correct args for each tip

* update increment test values

* make single channle QC test work with all tips in one run

* last few changes

* fixup typing error

* forgot a docstring for the linter

* support the enviornmental sensor in the volumetric tests

* make the asair prompt for port instead of auto finding

* fix the tests
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