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

feat (abr-testing): Low Volume 96ch Protocols + Full Liquid Set up Protocol #17475

Merged
merged 11 commits into from
Feb 14, 2025
67 changes: 62 additions & 5 deletions abr-testing/abr_testing/data_collection/abr_robot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,64 @@
from abr_testing.tools import plate_reader


def retrieve_protocol_file(
protocol_id: str,
def retrieve_version_file(
robot_ip: str,
storage: str,
) -> Path | str:
"""Find and copy protocol file on robot with error."""
protocol_dir = f"/var/lib/opentrons-robot-server/7.1/protocols/{protocol_id}"
"""Retrieve Version file."""
version_file_path = "/etc/VERSION.json"
save_dir = Path(f"{storage}")
print(save_dir)
command = ["scp", "-r", f"root@{robot_ip}:{version_file_path}", save_dir]
try:
subprocess.run(command, check=True) # type: ignore
return os.path.join(save_dir, "VERSION.json")
except subprocess.CalledProcessError as e:
print(f"Error during file transfer: {e}")
return ""


def retrieve_protocol_file(protocol_id: str, robot_ip: str, storage: str) -> Path | str:
"""Find and copy protocol file on robot with error handling."""
# List folders in the robot's directory
list_folder_command = [
"ssh",
f"root@{robot_ip}",
"ls /var/lib/opentrons-robot-server",
]
try:
result = subprocess.run(
list_folder_command, check=True, capture_output=True, text=True
)
folders = result.stdout.splitlines()

def convert_to_floats(data: List) -> List:
"""Convert list to floats."""
float_list = []
for item in data:
try:
float_value = float(item)
float_list.append(float_value)
except ValueError:
pass # Ignore items that cannot be converted to float
return float_list

folders_float = convert_to_floats(folders)
if not folders_float:
print("No folders found.")
return ""
folder_num = max(
folders_float
) # Assuming the highest folder number is the latest
if folder_num.is_integer():
folder_num = int(folder_num)
except subprocess.CalledProcessError:
print("Could not find folder.")
return ""
protocol_dir = (
f"/var/lib/opentrons-robot-server/{folder_num}/protocols/{protocol_id}"
)

# Copy protocol file found in robot onto host computer
save_dir = Path(f"{storage}")
command = ["scp", "-r", f"root@{robot_ip}:{protocol_dir}", save_dir]
Expand Down Expand Up @@ -366,6 +417,8 @@ def get_run_error_info_from_robot(
description = dict()
# get run information
results = get_run_logs.get_run_data(one_run, ip)
# Get version file

# save run information to local directory as .json file
saved_file_path = read_robot_logs.save_run_log_to_json(
ip, results, storage_directory
Expand Down Expand Up @@ -545,6 +598,8 @@ def get_run_error_info_from_robot(
except requests.exceptions.InvalidURL:
print("Invalid IP address.")
sys.exit()
version_file_dir = retrieve_version_file(robot_ip=ip, storage=storage_directory)
version_file_path = os.path.join(storage_directory, version_file_dir)
if len(run_or_other) < 1:
# Retrieve the most recently run protocol file
protocol_folder = retrieve_protocol_file(
Expand Down Expand Up @@ -611,12 +666,14 @@ def get_run_error_info_from_robot(
# OPEN TICKET
issue_url = ticket.open_issue(issue_key)
# MOVE FILES TO ERROR FOLDER.
print(version_file_path)
print(run_log_file_path)
error_files = [
saved_file_path_calibration,
run_log_file_path,
protocol_file_path,
version_file_path,
] + file_paths

error_folder_path = os.path.join(storage_directory, issue_key)
os.makedirs(error_folder_path, exist_ok=True)
for source_file in error_files:
Expand Down
5 changes: 4 additions & 1 deletion abr-testing/abr_testing/data_collection/get_run_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def get_run_data(one_run: Any, ip: str) -> Dict[str, Any]:
params={"cursor": 0, "pageLength": 0},
)
data = response.json()
command_count = data["meta"]["totalLength"]
try:
command_count = data["meta"]["totalLength"]
except KeyError:
command_count = 0
page_length = 100
commands = list()
run = dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ def tipcheck() -> None:
if trash_lid:
protocol.move_labware(lid_on_plate, trash_bin, use_gripper=True)
elif len(used_lids) <= 1:
protocol.move_labware(lid_on_plate, "B4", use_gripper=True)
protocol.move_labware(
lid_on_plate, deck_riser, use_gripper=True
)
else:
protocol.move_labware(
lid_on_plate, used_lids[-2], use_gripper=True
Expand Down
Loading
Loading