-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'edge' into refactor_input-prompt-and-fetch-data
- Loading branch information
Showing
723 changed files
with
9,637 additions
and
3,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,56 @@ | ||
"""Get Unique LPC Values from Run logs.""" | ||
"""Automated LPC Data Analysis.""" | ||
import os | ||
import argparse | ||
from abr_testing.automation import google_sheets_tool | ||
import sys | ||
|
||
|
||
def remove_duplicate_data() -> None: | ||
"""Determine unique sets of data.""" | ||
seen = set() | ||
new_values = [] | ||
row_indices = [] | ||
sheet_data = google_sheet_lpc.get_all_data() | ||
for i, row in enumerate(sheet_data): | ||
key = ( | ||
row["Robot"], | ||
row["Software Version"], | ||
row["Errors"], | ||
row["Slot"], | ||
row["Module"], | ||
row["Adapter"], | ||
row["X"], | ||
row["Y"], | ||
row["Z"], | ||
) | ||
|
||
if key not in seen: | ||
seen.add(key) | ||
new_values.append(row) | ||
else: | ||
row_indices.append(i) | ||
if len(row_indices) > 0: | ||
google_sheet_lpc.batch_delete_rows(row_indices) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Read run logs on google drive.") | ||
parser.add_argument( | ||
"storage_directory", | ||
metavar="STORAGE_DIRECTORY", | ||
type=str, | ||
nargs=1, | ||
help="Path to long term storage directory for run logs.", | ||
) | ||
args = parser.parse_args() | ||
storage_directory = args.storage_directory[0] | ||
try: | ||
credentials_path = os.path.join(storage_directory, "credentials.json") | ||
except FileNotFoundError: | ||
print(f"Add credentials.json file to: {storage_directory}.") | ||
sys.exit() | ||
google_sheet_lpc = google_sheets_tool.google_sheet(credentials_path, "ABR-LPC", 0) | ||
print(len(google_sheet_lpc.get_all_data())) | ||
remove_duplicate_data() | ||
num_of_rows = print(len(google_sheet_lpc.get_all_data())) | ||
# TODO: automate data analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,7 @@ | |
import shutil | ||
import os | ||
import subprocess | ||
import json | ||
import sys | ||
import gspread # type: ignore[import] | ||
|
||
|
||
def get_error_runs_from_robot(ip: str) -> List[str]: | ||
|
@@ -145,6 +143,7 @@ def get_error_info_from_robot( | |
whole_description_str, | ||
run_log_file_path, | ||
) = get_error_info_from_robot(ip, one_run, storage_directory) | ||
affects_version = "internal release - any" | ||
# Get Calibration Data | ||
saved_file_path_calibration, calibration = read_robot_logs.get_calibration_offsets( | ||
ip, storage_directory | ||
|
@@ -183,35 +182,31 @@ def get_error_info_from_robot( | |
# CONNECT TO GOOGLE DRIVE | ||
credentials_path = os.path.join(storage_directory, "credentials.json") | ||
google_sheet_name = "ABR-run-data" | ||
try: | ||
google_drive = google_drive_tool.google_drive( | ||
credentials_path, | ||
"1Cvej0eadFOTZr9ILRXJ0Wg65ymOtxL4m", | ||
"[email protected]", | ||
) | ||
print("Connected to google drive.") | ||
except json.decoder.JSONDecodeError: | ||
print( | ||
"Credential file is damaged. Get from https://console.cloud.google.com/apis/credentials" | ||
) | ||
sys.exit() | ||
google_drive = google_drive_tool.google_drive( | ||
credentials_path, | ||
"1Cvej0eadFOTZr9ILRXJ0Wg65ymOtxL4m", | ||
"[email protected]", | ||
) | ||
# CONNECT TO GOOGLE SHEET | ||
try: | ||
google_sheet = google_sheets_tool.google_sheet( | ||
credentials_path, google_sheet_name, 0 | ||
) | ||
print(f"Connected to google sheet: {google_sheet_name}") | ||
except gspread.exceptions.APIError: | ||
print("ERROR: Check google sheet name. Check credentials file.") | ||
sys.exit() | ||
google_sheet = google_sheets_tool.google_sheet( | ||
credentials_path, google_sheet_name, 0 | ||
) | ||
# WRITE ERRORED RUN TO GOOGLE SHEET | ||
error_run_log = os.path.join(error_folder_path, os.path.basename(run_log_file_path)) | ||
google_drive.upload_file(error_run_log) | ||
run_id = os.path.basename(error_run_log).split("_")[1].split(".")[0] | ||
runs_and_robots, headers = abr_google_drive.create_data_dictionary( | ||
run_id, error_folder_path, issue_url | ||
) | ||
( | ||
runs_and_robots, | ||
headers, | ||
runs_and_lpc, | ||
headers_lpc, | ||
) = abr_google_drive.create_data_dictionary(run_id, error_folder_path, issue_url) | ||
read_robot_logs.write_to_local_and_google_sheet( | ||
runs_and_robots, storage_directory, google_sheet_name, google_sheet, headers | ||
) | ||
print("Wrote run to ABR-run-data") | ||
# Add LPC to google sheet | ||
google_sheet_lpc = google_sheets_tool.google_sheet(credentials_path, "ABR-LPC", 0) | ||
read_robot_logs.write_to_local_and_google_sheet( | ||
runs_and_lpc, storage_directory, "ABR-LPC", google_sheet_lpc, headers_lpc | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.