-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added script to read individual files (#15028)
<!-- 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 Local Run Log Reader # Test Plan Tested on a folder of multiple run logs. --> # Changelog Added functions in google drive tool to download and search for files Added a script to look for files based on a local .json file with strings and download Added a script to allow for local run log reading without a google sheets upload. # 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
1 parent
3eb6a5d
commit c79c972
Showing
9 changed files
with
198 additions
and
103 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
51 changes: 51 additions & 0 deletions
51
abr-testing/abr_testing/data_collection/single_run_log_reader.py
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,51 @@ | ||
"""Reads single run log retrieved by get_run_logs.py and saves to local csv.""" | ||
import argparse | ||
import sys | ||
import os | ||
import csv | ||
from abr_testing.data_collection import read_robot_logs | ||
from abr_testing.data_collection import abr_google_drive | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Read single run log locally saved.") | ||
parser.add_argument( | ||
"run_log_file_path", | ||
metavar="RUN_LOG_FILE_PATH", | ||
type=str, | ||
nargs=1, | ||
help="Folder path that holds individual run logs of interest.", | ||
) | ||
parser.add_argument( | ||
"google_sheet_name", | ||
metavar="GOOGLE_SHEET_NAME", | ||
type=str, | ||
nargs=1, | ||
help="Google sheet name.", | ||
) | ||
args = parser.parse_args() | ||
run_log_file_path = args.run_log_file_path[0] | ||
google_sheet_name = args.google_sheet_name[0] | ||
|
||
try: | ||
credentials_path = os.path.join(run_log_file_path, "credentials.json") | ||
except FileNotFoundError: | ||
print(f"Add credentials.json file to: {run_log_file_path}.") | ||
sys.exit() | ||
# Get Runs from Storage and Read Logs | ||
run_ids_in_storage = read_robot_logs.get_run_ids_from_storage(run_log_file_path) | ||
runs_and_robots, header = abr_google_drive.create_data_dictionary( | ||
run_ids_in_storage, run_log_file_path, "" | ||
) | ||
list_of_runs = list(runs_and_robots.keys()) | ||
# Adds Run to local csv | ||
sheet_location = os.path.join(run_log_file_path, "saved_data.csv") | ||
file_exists = os.path.exists(sheet_location) and os.path.getsize(sheet_location) > 0 | ||
with open(sheet_location, "a", newline="") as f: | ||
writer = csv.writer(f) | ||
if not file_exists: | ||
writer.writerow(header) | ||
for run in list_of_runs: | ||
# Add new row | ||
row = runs_and_robots[run].values() | ||
row_list = list(row) | ||
writer.writerow(row_list) |
Oops, something went wrong.