Skip to content

Commit

Permalink
feat(abr-testing): Match JIRA component to ticket based off error mes…
Browse files Browse the repository at this point in the history
…sage (#15424)

<!--
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

Adds corresponding jira component to ticket.

# 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

Added `match_error_to_component()` in `abr_robot_error` .
function gets all components with corresponding project board. If the
error message contains a word that matches with the components, the
component is added to the ticket.

Small change - if error message is PythonException, the detail of the
error is added to the ticket title instead to make it more descriptive.

# 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
rclarke0 authored Jun 20, 2024
1 parent b69403e commit 53eb97b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
7 changes: 7 additions & 0 deletions abr-testing/abr_testing/automation/jira_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ def get_jira_users(self, storage_directory: str) -> str:
print("JSON decoding error occurred.")
return file_path

def get_project_components(self, project_id: str) -> List[Dict[str, str]]:
"""Get list of components on JIRA board."""
component_url = f"{self.url}/rest/api/3/project/{project_id}/components"
response = requests.get(component_url, headers=self.headers, auth=self.auth)
components_list = response.json()
return components_list


if __name__ == "__main__":
"""Create ticket for specified robot."""
Expand Down
24 changes: 21 additions & 3 deletions abr-testing/abr_testing/data_collection/abr_robot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
import subprocess
import sys
import json
import re


def match_error_to_component(
project_id: str, error_message: str, components: List[str]
) -> List[str]:
"""Match error to component based on error message."""
project_components = ticket.get_project_components(project_id)
component_names = [proj_comp["name"] for proj_comp in project_components]
for component in component_names:
pattern = re.compile(component, re.IGNORECASE)
matches = pattern.findall(error_message)
if matches:
components.append(component)
return components


def get_user_id(user_file_path: str, assignee_name: str) -> str:
Expand Down Expand Up @@ -76,9 +91,10 @@ def get_robot_state(
)
module_data = response.json()
for module in module_data["data"]:
print(module)
description[module["moduleType"]] = module
components = ["Flex-RABR"]
components = match_error_to_component("RABR", reported_string, components)
print(components)
whole_description_str = (
"{"
+ "\n".join("{!r}: {!r},".format(k, v) for k, v in description.items())
Expand Down Expand Up @@ -116,6 +132,8 @@ def get_run_error_info_from_robot(
failure_level = "Level " + str(error_level) + " Failure"

components = [failure_level, "Flex-RABR"]
components = match_error_to_component("RABR", error_type, components)
print(components)
affects_version = results["API_Version"]
parent = results.get("robot_name", "")
print(parent)
Expand Down Expand Up @@ -211,8 +229,8 @@ def get_run_error_info_from_robot(
except requests.exceptions.InvalidURL:
print("Invalid IP address.")
sys.exit()
one_run = error_runs[-1] # Most recent run with error.
if len(run_or_other) < 1:
one_run = error_runs[-1] # Most recent run with error.
(
summary,
robot,
Expand All @@ -234,7 +252,7 @@ def get_run_error_info_from_robot(
ip, storage_directory
)
file_paths = read_robot_logs.get_logs(storage_directory, ip)
print(f"Making ticket for run: {one_run} on robot {robot}.")
print(f"Making ticket for {summary}.")
# TODO: make argument or see if I can get rid of with using board_id.
project_key = "RABR"
parent_key = project_key + "-" + robot[-1]
Expand Down
3 changes: 3 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 @@ -383,6 +383,9 @@ def get_error_info(file_results: Dict[str, Any]) -> Tuple[int, str, str, str, st
error_str = 0
if error_str > 1:
error_type = run_command_error["error"].get("errorType", "")
if error_type == "PythonException":
# Reassign error_type to be more descriptive
error_type = run_command_error["detail"].split(":")[0]
error_code = run_command_error["error"].get("errorCode", "")
try:
# Instrument Error
Expand Down

0 comments on commit 53eb97b

Please sign in to comment.