Skip to content

Commit

Permalink
fix(abr-testing): added error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rclarke0 committed Jun 27, 2024
1 parent df54e47 commit 87b0bd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 9 additions & 5 deletions abr-testing/abr_testing/data_collection/get_run_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
def get_run_ids_from_robot(ip: str) -> Set[str]:
"""Get all completed runs from each robot."""
run_ids = set()
response = requests.get(
f"http://{ip}:31950/runs", headers={"opentrons-version": "3"}
)
run_data = response.json()
run_list = run_data["data"]
try:
response = requests.get(
f"http://{ip}:31950/runs", headers={"opentrons-version": "3"}
)
run_data = response.json()
run_list = run_data["data"]
except requests.exceptions.RequestException:
print(f"Could not connect to robot with IP {ip}")
run_list = []
for run in run_list:
run_id = run["id"]
if not run["current"]:
Expand Down
8 changes: 6 additions & 2 deletions abr-testing/abr_testing/tools/sync_abr_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
def determine_lifetime(abr_google_sheet: Any) -> None:
"""Record lifetime % of robot, pipettes, and gripper per run."""
# Get all data
all_google_data = abr_google_sheet.get_all_data()
headers = abr_google_sheet.get_row(1)
all_google_data = abr_google_sheet.get_all_data(expected_headers=headers)
# Convert dictionary to pandas dataframe
df_sheet_data = pd.DataFrame.from_dict(all_google_data)
df_sheet_data["Start_Time"] = pd.to_datetime(
Expand All @@ -27,7 +28,10 @@ def determine_lifetime(abr_google_sheet: Any) -> None:
for index, run in df_sheet_data.iterrows():
end_time = run["End_Time"]
robot = run["Robot"]
if len(run["Robot Lifetime (%)"]) < 1 and len(run["Run_ID"]) > 1:
robot_lifetime = (
float(run["Robot Lifetime (%)"]) if run["Robot Lifetime (%)"] != "" else 0
)
if robot_lifetime < 1 and len(run["Run_ID"]) > 1:
# Get Robot % Lifetime
robot_runs_before = df_sheet_data[
(df_sheet_data["End_Time"] <= end_time)
Expand Down

0 comments on commit 87b0bd8

Please sign in to comment.