Skip to content

Commit

Permalink
automatically assign IP and expected volume moved (#15597)
Browse files Browse the repository at this point in the history
<!--
Thanks for taking the time to open a pull request! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

<!--
Added section to read a json file in the measurement folder containing
all robot IP's and expected volumes moved based on robot name.-->

# Test Plan

<!--
Tested steps 1, 2, and 3 with measurements. I do not believe more
testing is needed.
-->

# Changelog

<!--
- added json file reader for IP's and volumes
- added recovery if "Y" or "N" were not input after a measurement
-->

# Review requests

<!--
N/A
-->

# Risk assessment

<!--
This script is not relied on in any other script.
-->
  • Loading branch information
nbshiland authored Jul 10, 2024
1 parent 7cf3dbe commit c8640a3
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions abr-testing/abr_testing/tools/abr_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import requests
from typing import Any, Tuple
import sys
import json


def get_protocol_step_as_int() -> Tuple[int, float, str]:
def get_protocol_step_as_int(
storage_directory: str, robot: str
) -> Tuple[int, float, str]:
"""Get user input as integer."""
expected_liquid_moved = 0.0
ip = ""
Expand All @@ -26,14 +29,25 @@ def get_protocol_step_as_int() -> Tuple[int, float, str]:
print("Protocol step should be an integer value 1, 2, or 3.")

if int(protocol_step) == 3:
ip = input("Robot IP: ")
while True:
try:
expected_liquid_moved = float(input("Expected volume moved: "))
if expected_liquid_moved >= 0 or expected_liquid_moved <= 0:
break
except ValueError:
print("Expected liquid moved volume should be an float.")
# setup IP sheet
ip_json_file = os.path.join(storage_directory, "IP_N_VOLUMES.json")
# create an dict copying the contents of IP_N_Volumes
try:
ip_file = json.load(open(ip_json_file))
except FileNotFoundError:
print(
f"Please add json file with robot IPs and expected volumes to: {storage_directory}."
)
sys.exit()
# grab IP and volume from the dict
tot_info = ip_file["information"]
robot_info = tot_info[robot]
IP_add = robot_info["IP"]
exp_volume = robot_info["volume"]
# sets return variables equal to those grabbed from the sheet
ip = IP_add
expected_liquid_moved = float(exp_volume)

return protocol_step, expected_liquid_moved, ip


Expand Down Expand Up @@ -170,8 +184,11 @@ def get_most_recent_run_and_record(
)
robot = input("Robot: ")
labware = input("Labware: ")
protocol_step, expected_liquid_moved, ip = get_protocol_step_as_int()

protocol_step, expected_liquid_moved, ip = get_protocol_step_as_int(
storage_directory, robot
)
print(ip)
print(expected_liquid_moved)
# Scale Loop
grams, is_stable = scale.read_mass()
grams, is_stable = scale.read_mass()
Expand Down Expand Up @@ -199,16 +216,23 @@ def get_most_recent_run_and_record(
get_most_recent_run_and_record(ip, storage_directory, labware, accuracy)

is_stable = False
y_or_no = input("Do you want to weigh another sample? (Y/N): ")
if y_or_no == "Y":
# Uses same storage directory and file.
grams, is_stable = scale.read_mass()
is_stable = False
robot = input("Robot: ")
labware = input("Labware: ")
protocol_step, expected_liquid_moved, ip = get_protocol_step_as_int()
grams, is_stable = scale.read_mass()
elif y_or_no == "N":
break_all = True
while True:
y_or_no = input("Do you want to weigh another sample? (Y/N): ")
if y_or_no == "Y" or y_or_no == "y":
# Uses same storage directory and file.
grams, is_stable = scale.read_mass()
is_stable = False
robot = input("Robot: ")
labware = input("Labware: ")
protocol_step, expected_liquid_moved, ip = get_protocol_step_as_int(
storage_directory, robot
)
grams, is_stable = scale.read_mass()
break
elif y_or_no == "N" or y_or_no == "n":
break_all = True
break
else:
print("Please Choose a Valid Option")
if break_all:
break

0 comments on commit c8640a3

Please sign in to comment.