-
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.
<!-- Thanks for taking the time to open a pull request! Please make sure you've read the "Opening Pull Requests" section of our Contributing Guide: https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests To ensure your code is reviewed quickly and thoroughly, please fill out the sections below to the best of your ability! --> # Overview <!-- Use this section to describe your pull-request at a high level. If the PR addresses any open issues, please tag the issues here. --> # Test Plan <!-- Use this section to describe the steps that you took to test your Pull Request. If you did not perform any testing provide justification why. OT-3 Developers: You should default to testing on actual physical hardware. Once again, if you did not perform testing against hardware, justify why. Note: It can be helpful to write a test plan before doing development Example Test Plan (HTTP API Change) - Verified that new optional argument `dance-party` causes the robot to flash its lights, move the pipettes, then home. - Verified that when you omit the `dance-party` option the robot homes normally - Added protocol that uses `dance-party` argument to G-Code Testing Suite - Ran protocol that did not use `dance-party` argument and everything was successful - Added unit tests to validate that changes to pydantic model are correct --> # Changelog <!-- List out the changes to the code in this PR. Please try your best to categorize your changes and describe what has changed and why. Example changelog: - Fixed app crash when trying to calibrate an illegal pipette - Added state to API to track pipette usage - Updated API docs to mention only two pipettes are supported IMPORTANT: MAKE SURE ANY BREAKING CHANGES ARE PROPERLY COMMUNICATED --> # Review requests <!-- Describe any requests for your reviewers here. --> # Risk assessment <!-- Carefully go over your pull request and look at the other parts of the codebase it may affect. Look for the possibility, even if you think it's small, that your change may affect some other part of the system - for instance, changing return tip behavior in protocol may also change the behavior of labware calibration. Identify the other parts of the system your codebase may affect, so that in addition to your own review and testing, other people who may not have the system internalized as much as you can focus their attention and testing there. -->
- Loading branch information
Showing
6 changed files
with
196 additions
and
52 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
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