From da74897b48452a237387040b8d43ab1b8ab80224 Mon Sep 17 00:00:00 2001 From: Anthony Ngumah <68346382+AnthonyNASC20@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:43:42 -0500 Subject: [PATCH] fix(abr-testing): unify all script compatibility with same ip file (#16922) # Overview Ensures data collection scripts can all use the same IPs.json file when connecting to robots --------- Co-authored-by: rclarke0 --- .../data_collection/abr_calibration_logs.py | 3 ++- .../abr_testing/data_collection/get_run_logs.py | 3 ++- .../hardware_testing/scripts/ABRAsairScript.py | 12 +++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/abr-testing/abr_testing/data_collection/abr_calibration_logs.py b/abr-testing/abr_testing/data_collection/abr_calibration_logs.py index 75b73b8f16b..46cc409e53d 100644 --- a/abr-testing/abr_testing/data_collection/abr_calibration_logs.py +++ b/abr-testing/abr_testing/data_collection/abr_calibration_logs.py @@ -286,6 +286,7 @@ def run( ip_json_file = os.path.join(storage_directory, "IPs.json") try: ip_file = json.load(open(ip_json_file)) + robot_dict = ip_file.get("ip_address_list") except FileNotFoundError: print(f"Add .json file with robot IPs to: {storage_directory}.") sys.exit() @@ -294,7 +295,7 @@ def run( ip_or_all = input("IP Address or ALL: ") calibration_data = [] if ip_or_all.upper() == "ALL": - ip_address_list = ip_file["ip_address_list"] + ip_address_list = list(robot_dict.keys()) for ip in ip_address_list: saved_file_path, calibration = read_robot_logs.get_calibration_offsets( ip, storage_directory diff --git a/abr-testing/abr_testing/data_collection/get_run_logs.py b/abr-testing/abr_testing/data_collection/get_run_logs.py index 964a8a06e18..fe89f9f1543 100644 --- a/abr-testing/abr_testing/data_collection/get_run_logs.py +++ b/abr-testing/abr_testing/data_collection/get_run_logs.py @@ -104,10 +104,11 @@ def get_all_run_logs( ip_json_file = os.path.join(storage_directory, "IPs.json") try: ip_file = json.load(open(ip_json_file)) + robot_dict = ip_file.get("ip_address_list") except FileNotFoundError: print(f"Add .json file with robot IPs to: {storage_directory}.") sys.exit() - ip_address_list = ip_file["ip_address_list"] + ip_address_list = list(robot_dict.keys()) runs_from_storage = read_robot_logs.get_run_ids_from_google_drive(google_drive) for ip in ip_address_list: runs = get_run_ids_from_robot(ip) diff --git a/hardware-testing/hardware_testing/scripts/ABRAsairScript.py b/hardware-testing/hardware_testing/scripts/ABRAsairScript.py index 41c70ed35a2..710d3c17578 100644 --- a/hardware-testing/hardware_testing/scripts/ABRAsairScript.py +++ b/hardware-testing/hardware_testing/scripts/ABRAsairScript.py @@ -2,6 +2,7 @@ import sys import paramiko as pmk import time +import json import multiprocessing from typing import Optional, List, Any @@ -69,11 +70,10 @@ def run(file_name: str) -> List[Any]: robot_ips = [] robot_names = [] with open(file_name) as file: - for line in file.readlines(): - info = line.split(",") - if "Y" in info[2]: - robot_ips.append(info[0]) - robot_names.append(info[1]) + file_dict = json.load(file) + robot_dict = file_dict.get("ip_address_list") + robot_ips = list(robot_dict.keys()) + robot_names = list(robot_dict.values()) print("Executing Script on All Robots:") # Launch the processes for each robot. processes = [] @@ -89,10 +89,8 @@ def run(file_name: str) -> List[Any]: # Wait for all processes to finish. file_name = sys.argv[1] processes = run(file_name) - for process in processes: process.start() time.sleep(20) - for process in processes: process.join()