-
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 app_odd-anonymous-localization-provider
- Loading branch information
Showing
267 changed files
with
8,754 additions
and
1,908 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Get Unique LPC Values from Run logs.""" |
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 |
---|---|---|
|
@@ -3,7 +3,13 @@ | |
from abr_testing.data_collection import read_robot_logs, abr_google_drive, get_run_logs | ||
import requests | ||
import argparse | ||
from abr_testing.automation import jira_tool | ||
from abr_testing.automation import jira_tool, google_sheets_tool, google_drive_tool | ||
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]: | ||
|
@@ -44,7 +50,6 @@ def get_error_info_from_robot( | |
# JIRA Ticket Fields | ||
failure_level = "Level " + str(error_level) + " Failure" | ||
components = [failure_level, "Flex-RABR"] | ||
components = ["Flex-RABR"] | ||
affects_version = results["API_Version"] | ||
parent = results.get("robot_name", "") | ||
print(parent) | ||
|
@@ -86,13 +91,6 @@ def get_error_info_from_robot( | |
nargs=1, | ||
help="Path to long term storage directory for run logs.", | ||
) | ||
parser.add_argument( | ||
"robot_ip", | ||
metavar="ROBOT_IP", | ||
type=str, | ||
nargs=1, | ||
help="IP address of robot as string.", | ||
) | ||
parser.add_argument( | ||
"jira_api_token", | ||
metavar="JIRA_API_TOKEN", | ||
|
@@ -125,33 +123,39 @@ def get_error_info_from_robot( | |
) | ||
args = parser.parse_args() | ||
storage_directory = args.storage_directory[0] | ||
ip = args.robot_ip[0] | ||
ip = str(input("Enter Robot IP: ")) | ||
url = "https://opentrons.atlassian.net" | ||
api_token = args.jira_api_token[0] | ||
email = args.email[0] | ||
board_id = args.board_id[0] | ||
reporter_id = args.reporter_id[0] | ||
ticket = jira_tool.JiraTicket(url, api_token, email) | ||
error_runs = get_error_runs_from_robot(ip) | ||
try: | ||
error_runs = get_error_runs_from_robot(ip) | ||
except requests.exceptions.InvalidURL: | ||
print("Invalid IP address.") | ||
sys.exit() | ||
one_run = error_runs[-1] # Most recent run with error. | ||
( | ||
summary, | ||
robot, | ||
affects_version, | ||
components, | ||
whole_description_str, | ||
saved_file_path, | ||
run_log_file_path, | ||
) = get_error_info_from_robot(ip, one_run, storage_directory) | ||
# get calibration data | ||
# Get Calibration Data | ||
saved_file_path_calibration, calibration = read_robot_logs.get_calibration_offsets( | ||
ip, storage_directory | ||
) | ||
file_paths = read_robot_logs.get_logs(storage_directory, ip) | ||
print(f"Making ticket for run: {one_run} on robot {robot}.") | ||
# TODO: make argument or see if I can get rid of with using board_id. | ||
project_key = "RABR" | ||
parent_key = project_key + "-" + robot[-1] | ||
issues_ids = ticket.issues_on_board(board_id) | ||
issue_url, issue_key = ticket.create_ticket( | ||
# TODO: read board to see if ticket for run id already exists. | ||
# CREATE TICKET | ||
issue_key = ticket.create_ticket( | ||
summary, | ||
whole_description_str, | ||
project_key, | ||
|
@@ -162,6 +166,51 @@ def get_error_info_from_robot( | |
affects_version, | ||
parent_key, | ||
) | ||
ticket.open_issue(issue_key) | ||
ticket.post_attachment_to_ticket(issue_key, saved_file_path) | ||
ticket.post_attachment_to_ticket(issue_key, saved_file_path_calibration) | ||
# OPEN TICKET | ||
issue_url = ticket.open_issue(issue_key) | ||
# MOVE FILES TO ERROR FOLDER. | ||
error_files = [saved_file_path_calibration, run_log_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: | ||
destination_file = os.path.join( | ||
error_folder_path, os.path.basename(source_file) | ||
) | ||
shutil.move(source_file, destination_file) | ||
# OPEN FOLDER DIRECTORY | ||
subprocess.Popen(["explorer", error_folder_path]) | ||
# 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() | ||
# 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() | ||
# 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 | ||
) | ||
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") |
Oops, something went wrong.