Skip to content

Commit

Permalink
fix(abr-testing): fix file upload and error instrument serial number …
Browse files Browse the repository at this point in the history
…recording (#17277)

<!--
Thanks for taking the time to open a Pull Request (PR)! 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

GitHub provides robust markdown to format your PR. Links, diagrams,
pictures, and videos along with text formatting make it possible to
create a rich and informative PR. For more information on GitHub
markdown, see:


https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

Fix file upload to jira ticket and give more specific information for
error instrument

## Test Plan and Hands on Testing

tested on robot

## Changelog

ensures just the protocol file is uploaded by moving it into the correct
folder and checking that it is a .py file
uses the error node to find the appropriate serial number for errored
instrument

## Review requests

<!--
- What do you need from reviewers to feel confident this PR is ready to
merge?
- Ask questions.
-->

## Risk assessment

<!--
- Indicate the level of attention this PR needs.
- Provide context to guide reviewers.
- Discuss trade-offs, coupling, and side effects.
- 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 may also change the
behavior of labware calibration.
- How do your unit tests and on hands on testing mitigate this PR's
risks and the risk of future regressions?
- Especially in high risk PRs, explain how you know your testing is
enough.
-->
  • Loading branch information
rclarke0 authored Jan 15, 2025
1 parent eca564a commit 9ab7ba9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
35 changes: 16 additions & 19 deletions abr-testing/abr_testing/data_collection/abr_robot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ def retrieve_protocol_file(
) -> Path | str:
"""Find and copy protocol file on robot with error."""
protocol_dir = f"/var/lib/opentrons-robot-server/7.1/protocols/{protocol_id}"

print(f"FILE TO FIND: {protocol_dir}/{protocol_id}")
# Copy protocol file found in robot oto host computer
save_dir = Path(f"{storage}/protocol_errors")
# Copy protocol file found in robot onto host computer
save_dir = Path(f"{storage}")
command = ["scp", "-r", f"root@{robot_ip}:{protocol_dir}", save_dir]
try:
# If file found and copied return path to file
Expand Down Expand Up @@ -62,7 +60,6 @@ def compare_current_trh_to_average(
# Find average conditions of errored time period
df_all_trh = pd.DataFrame(all_trh_data)
# Convert timestamps to datetime objects
print(f'TIMESTAMP: {df_all_trh["Timestamp"]}')
try:
df_all_trh["Timestamp"] = pd.to_datetime(
df_all_trh["Timestamp"], format="mixed", utc=True
Expand Down Expand Up @@ -196,7 +193,6 @@ def read_each_log(folder_path: str, issue_url: str) -> None:
for file_name in os.listdir(folder_path):
file_path = os.path.join(folder_path, file_name)
not_found_words = []
print(file_path)
if file_path.endswith(".log"):
with open(file_path) as file:
lines = file.readlines()
Expand Down Expand Up @@ -341,11 +337,8 @@ def get_robot_state(
if "8.2" in affects_version:
labels.append("8_2_0")
parent = affects_version + " Bugs"
print(components)
end_time = datetime.now()
print(end_time)
start_time = end_time - timedelta(hours=2)
print(start_time)
# Get current temp/rh compared to historical data
temp_rh_string = compare_current_trh_to_average(
parent, start_time, end_time, "", storage_directory
Expand Down Expand Up @@ -554,11 +547,17 @@ def get_run_error_info_from_robot(
sys.exit()
if len(run_or_other) < 1:
# Retrieve the most recently run protocol file
protocol_files_path = retrieve_protocol_file(
protocol_folder = retrieve_protocol_file(
protocol_ids[-1], ip, storage_directory
)
protocol_folder_path = os.path.join(protocol_folder, protocol_ids[-1])
# Path to protocol folder
list_of_files = os.listdir(protocol_folder_path)
for file in list_of_files:
if str(file).endswith(".py"):
protocol_file_path = os.path.join(protocol_folder_path, file)
# Set protocol_found to true if python protocol was successfully copied over
if protocol_files_path:
if protocol_file_path:
protocol_found = True

one_run = error_runs[-1] # Most recent run with error.
Expand Down Expand Up @@ -612,15 +611,13 @@ def get_run_error_info_from_robot(
# OPEN TICKET
issue_url = ticket.open_issue(issue_key)
# MOVE FILES TO ERROR FOLDER.
print(protocol_files_path)
error_files = [saved_file_path_calibration, run_log_file_path] + file_paths

# Move protocol file(s) to error folder
if protocol_files_path:
for file in os.listdir(protocol_files_path):
error_files.append(os.path.join(protocol_files_path, file))
error_files = [
saved_file_path_calibration,
run_log_file_path,
protocol_file_path,
] + file_paths

error_folder_path = os.path.join(storage_directory, "issue_key")
error_folder_path = os.path.join(storage_directory, issue_key)
os.makedirs(error_folder_path, exist_ok=True)
for source_file in error_files:
try:
Expand Down
16 changes: 16 additions & 0 deletions abr-testing/abr_testing/data_collection/read_robot_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ def get_error_info(file_results: Dict[str, Any]) -> Dict[str, Any]:
recoverable_errors.get(error_type, 0) + 1
)
# Get run-ending error info
module_dict = {
"heatershaker": "heaterShakerModuleV1",
"thermocycler": "thermocyclerModuleV2",
"temperature module": "temperatureModuleV2",
}
try:
run_command_error = commands_of_run[-1]["error"]
error_type = run_command_error.get("errorType", "")
Expand All @@ -647,6 +652,17 @@ def get_error_info(file_results: Dict[str, Any]) -> Dict[str, Any]:
error_instrument = run_command_error.get("errorInfo", {}).get(
"node", run_command_error.get("errorInfo", {}).get("port", "")
)
if "gripper" in error_instrument:
# get gripper serial number
error_instrument = file_results["extension"]
else:
# get module serial number
for module in module_dict.keys():
if module in error_instrument:
for module_list in file_results["modules"]:
model = module_list["model"]
if model == module_dict[module]:
error_instrument = module_list["serialNumber"]
except (IndexError, KeyError):
try:
error_details = file_results.get("errors", [{}])[0]
Expand Down

0 comments on commit 9ab7ba9

Please sign in to comment.