Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
andySigler committed Dec 19, 2024
1 parent ba74f93 commit 77f44b4
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 37 deletions.
20 changes: 11 additions & 9 deletions hardware-testing/hardware_testing/gravimetric/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def _get_protocol_context(cls, args: argparse.Namespace) -> ProtocolContext:
API_LEVEL, # type: ignore[attr-defined]
is_simulating=args.simulate,
pipette_left=PIPETTE_MODEL_NAME[args.pipette][args.channels],
pipette_right=PIPETTE_MODEL_NAME[args.pipette][args.channels] if args.channels < 96 else None,
pipette_right=PIPETTE_MODEL_NAME[args.pipette][args.channels]
if args.channels < 96
else None,
extra_labware=custom_defs,
)
for offset in LABWARE_OFFSETS:
Expand Down Expand Up @@ -390,7 +392,7 @@ def build_run_args(cls, args: argparse.Namespace) -> "RunArgs": # noqa: C901
test_report=report,
liquid=args.liquid,
dilution=args.dilution,
reverse_tips=args.reverse_tips
reverse_tips=args.reverse_tips,
)


Expand Down Expand Up @@ -644,12 +646,8 @@ def _main(
parser.add_argument(
"--starting-tip",
type=str,
choices=[
f"{c}{str(r + 1)}"
for r in range(12)
for c in "ABCDEFGH"
],
default="A1"
choices=[f"{c}{str(r + 1)}" for r in range(12) for c in "ABCDEFGH"],
default="A1",
)
args = parser.parse_args()
run_args = RunArgs.build_run_args(args)
Expand All @@ -671,7 +669,11 @@ def _main(
# NOTE: there is a chance that the pipette has a tip still attached
# from a previous run (eg: previous run ended in error)
# so here we just assume there's a tip and drop the tip no matter what
hw_mount = helpers.OT3Mount.LEFT if run_args.pipette.mount == "left" else helpers.OT3Mount.RIGHT
hw_mount = (
helpers.OT3Mount.LEFT
if run_args.pipette.mount == "left"
else helpers.OT3Mount.RIGHT
)
hw.add_tip(hw_mount, tip_length=120) # langer than any tip, to be safe
run_args.pipette.move_to(run_args.pipette.trash_container)
hw.drop_tip(hw_mount)
Expand Down
33 changes: 22 additions & 11 deletions hardware-testing/hardware_testing/gravimetric/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
_sense_liquid_height,
_pick_up_tip,
_drop_tip,
get_pipette_unique_name
get_pipette_unique_name,
)
from .trial import (
build_gravimetric_trials,
Expand Down Expand Up @@ -344,7 +344,9 @@ def _record_measurement_and_store(m_type: MeasurementType) -> MeasurementData:
raise NotImplementedError("mix testing not implemented")

# center channel over well
trial.pipette.move_to(trial.well.top(config.VIAL_SAFE_Z_OFFSET).move(trial.channel_offset))
trial.pipette.move_to(
trial.well.top(config.VIAL_SAFE_Z_OFFSET).move(trial.channel_offset)
)
if trial.cfg.lld_every_tip:
liq_height = _get_liquid_height(
trial.ctx,
Expand Down Expand Up @@ -630,10 +632,16 @@ def run(cfg: config.GravimetricConfig, resources: TestResources) -> None: # noq
"P50SV3520230812A17": "A",
"P50SV3520230724A01": "B",
"P50SV3520230724A02": "C",
"P50SV3520231024A11": "D"
"P50SV3520231024A11": "D",
}
unit_tag: str = UNITS.get(get_pipette_unique_name(resources.pipette), "S")
meta_data: List[str] = [resources.test_report._run_id, cfg.liquid, f"P{cfg.pipette_volume}S", unit_tag, str(cfg.tip_volume)]
meta_data: List[str] = [
resources.test_report._run_id,
cfg.liquid,
f"P{cfg.pipette_volume}S",
unit_tag,
str(cfg.tip_volume),
]
simplified_results_for_calibration_test: List[List[str]] = []

total_tips = len(
Expand Down Expand Up @@ -670,7 +678,9 @@ def run(cfg: config.GravimetricConfig, resources: TestResources) -> None: # noq
try:
well = labware_on_scale["A1"]
if cfg.jog or cfg.blank or not cfg.lld_every_tip:
first_tip = _next_tip_for_channel(cfg, resources, 0, total_tips, tip_name=cfg.starting_tip)
first_tip = _next_tip_for_channel(
cfg, resources, 0, total_tips, tip_name=cfg.starting_tip
)
setup_channel_offset = _get_channel_offset(cfg, channel=0)
first_tip_location = first_tip.top().move(setup_channel_offset)
resources.pipette._retract()
Expand Down Expand Up @@ -827,7 +837,9 @@ def run(cfg: config.GravimetricConfig, resources: TestResources) -> None: # noq
# FIXME: see why it takes so long to store CSV data
resources.test_report.save_to_disk()

simplified_results_for_calibration_test[-1].append(str(round(asp_with_evap, 2)))
simplified_results_for_calibration_test[-1].append(
str(round(asp_with_evap, 2))
)

ui.print_info("dropping tip")
if not cfg.same_tip:
Expand Down Expand Up @@ -990,14 +1002,13 @@ def run(cfg: config.GravimetricConfig, resources: TestResources) -> None: # noq
channel_count=len(channels_to_test),
test_report=resources.test_report,
)
csv_data_str = "\n".join([
"\t".join(csv_line)
for csv_line in simplified_results_for_calibration_test
])
csv_data_str = "\n".join(
["\t".join(csv_line) for csv_line in simplified_results_for_calibration_test]
)
print(csv_data_str)
dump_data_to_file(
resources.test_report._test_name,
resources.test_report._run_id,
f"aspirate-volumes-{resources.test_report._tag}.csv",
csv_data_str
csv_data_str,
)
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,24 @@ def _interp(lower: float, upper: float) -> float:
delay=_interp(a.aspirate.delay, b.aspirate.delay),
retract_mm=_interp(a.aspirate.retract_mm, b.aspirate.retract_mm),
air_gap=_interp(a.aspirate.air_gap, b.aspirate.air_gap),
retract_delay=_interp(a.aspirate.retract_delay, b.aspirate.retract_delay)
retract_delay=_interp(a.aspirate.retract_delay, b.aspirate.retract_delay),
),
dispense=DispenseSettings(
z_speed=_interp(a.dispense.z_speed, b.dispense.z_speed),
submerge_mm=_interp(a.dispense.submerge_mm, b.dispense.submerge_mm),
flow_rate=_interp(a.dispense.flow_rate, b.dispense.flow_rate),
break_off_flow_acceleration=_interp(a.dispense.break_off_flow_acceleration, b.dispense.break_off_flow_acceleration),
break_off_flow_rate=_interp(a.dispense.break_off_flow_rate, b.dispense.break_off_flow_rate),
break_off_flow_acceleration=_interp(
a.dispense.break_off_flow_acceleration,
b.dispense.break_off_flow_acceleration,
),
break_off_flow_rate=_interp(
a.dispense.break_off_flow_rate, b.dispense.break_off_flow_rate
),
break_off_ul=_interp(a.dispense.break_off_ul, b.dispense.break_off_ul),
delay=_interp(a.dispense.delay, b.dispense.delay),
retract_mm=_interp(a.dispense.retract_mm, b.dispense.retract_mm),
push_out=_interp(a.dispense.push_out, b.dispense.push_out),
blow_out=a.dispense.blow_out or b.dispense.blow_out,
retract_delay=_interp(a.dispense.retract_delay, b.dispense.retract_delay)
retract_delay=_interp(a.dispense.retract_delay, b.dispense.retract_delay),
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ def _aspirate_on_submerge() -> None:
)

def _aspirate_on_retract() -> None:
if liquid_class.aspirate.retract_delay and liquid_class.aspirate.submerge_mm < 0:
if (
liquid_class.aspirate.retract_delay
and liquid_class.aspirate.submerge_mm < 0
):
# NOTE: residual liquid on outside of tip will drop down to bottom of tip
# after retracting from liquid. If we air-gap too soon before
# said liquid slides down to bottom of tip, the air-gap we create
Expand Down Expand Up @@ -257,7 +260,9 @@ def _dispense_on_approach() -> None:
# adhering to outside of tip.
likely_a_contact_dispense = liquid_class.dispense.submerge_mm <= 1
if not blank and has_air_gap and likely_a_contact_dispense:
pipette.flow_rate.dispense = max(liquid_class.aspirate.air_gap, 1) # 1 second (minimum)
pipette.flow_rate.dispense = max(
liquid_class.aspirate.air_gap, 1
) # 1 second (minimum)
pipette.dispense(liquid_class.aspirate.air_gap)
pipette.flow_rate.dispense = liquid_class.dispense.flow_rate

Expand All @@ -276,28 +281,41 @@ def _dispense_on_submerge() -> None:
), f"push-out ({push_out}) cannot exceed {_get_max_blow_out_ul()}"
if not break_off:
if liquid_class.dispense.break_off_flow_acceleration:
hw_pipette.flow_acceleration = liquid_class.dispense.break_off_flow_acceleration
hw_pipette.flow_acceleration = (
liquid_class.dispense.break_off_flow_acceleration
)
pipette.dispense(push_out=push_out)
else:
assert push_out is not None, \
"push-out must be specified when setting a break-off volume"
assert (
push_out is not None
), "push-out must be specified when setting a break-off volume"
if break_off == push_out:
break_off = push_out + 0.1

def _break_off_cfg() -> None:
pipette.flow_rate.dispense = liquid_class.dispense.break_off_flow_rate
pipette.flow_rate.blow_out = liquid_class.dispense.break_off_flow_rate
hw_api.set_flow_rate(hw_mount, blow_out=liquid_class.dispense.break_off_flow_rate)
pipette.flow_rate.dispense = (
liquid_class.dispense.break_off_flow_rate
)
pipette.flow_rate.blow_out = (
liquid_class.dispense.break_off_flow_rate
)
hw_api.set_flow_rate(
hw_mount, blow_out=liquid_class.dispense.break_off_flow_rate
)
if liquid_class.dispense.break_off_flow_acceleration:
hw_pipette.flow_acceleration = liquid_class.dispense.break_off_flow_acceleration
hw_pipette.flow_acceleration = (
liquid_class.dispense.break_off_flow_acceleration
)

if break_off < push_out:
# 1) dispense w/ push-out (minus break-out ul)
_reduced_push_out_ul = push_out - break_off
pipette.dispense(push_out=_reduced_push_out_ul)
# 2) blow-out using break-off ul and speed
_break_off_cfg()
hw_api.blow_out(OT3Mount.LEFT, push_out) # NOTE: volume is absolute below "bottom"
hw_api.blow_out(
OT3Mount.LEFT, push_out
) # NOTE: volume is absolute below "bottom"
elif break_off > push_out:
# 1) dispense a reduced amount
_remaining_ul = break_off - push_out
Expand All @@ -308,7 +326,9 @@ def _break_off_cfg() -> None:
finally:
hw_pipette.flow_acceleration = default_flow_accel
pipette.flow_rate.dispense = liquid_class.dispense.flow_rate
hw_api.set_flow_rate(hw_mount, blow_out=liquid_class.dispense.flow_rate) # FIXME: is this correct?
hw_api.set_flow_rate(
hw_mount, blow_out=liquid_class.dispense.flow_rate
) # FIXME: is this correct?
# delay
_delay_seconds = liquid_class.dispense.delay
if liquid_class.dispense.submerge_mm >= 0:
Expand All @@ -321,7 +341,10 @@ def _break_off_cfg() -> None:
)

def _dispense_on_retract() -> None:
if liquid_class.dispense.retract_delay and liquid_class.dispense.submerge_mm < 0:
if (
liquid_class.dispense.retract_delay
and liquid_class.dispense.submerge_mm < 0
):
# NOTE: if non-contact dispense, the "retract" delay should have already happened
ctx.delay(seconds=liquid_class.dispense.retract_delay)
# NOTE: both the plunger reset or tje trailing-air-gap
Expand All @@ -342,7 +365,9 @@ def _dispense_on_retract() -> None:
# PHASE 1: APPROACH
pipette.flow_rate.aspirate = liquid_class.aspirate.flow_rate
pipette.flow_rate.dispense = liquid_class.dispense.flow_rate
pipette.flow_rate.blow_out = liquid_class.dispense.flow_rate # FIXME: is this correct?
pipette.flow_rate.blow_out = (
liquid_class.dispense.flow_rate
) # FIXME: is this correct?

pipette.move_to(well.bottom(approach_mm).move(channel_offset))
_aspirate_on_approach() if aspirate or mix else _dispense_on_approach()
Expand Down

0 comments on commit 77f44b4

Please sign in to comment.