Skip to content

Commit dbe2afe

Browse files
authored
feat (abr-testing): Add labels to ABR Jira Tickets (#16805)
<!-- 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 Add labels to ABR JIRA Tickets ## Test Plan and Hands on Testing Tested script with different robots on different software changes ## Changelog - Adding label for if SW version is 8.2.0 - Added label if SW version is an internal release by searching for substring "alpha" - Added additional error handling for pulling data from ABR data sheets - Removed parent field - will revisit this later - ## 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. -->
1 parent 378a1f2 commit dbe2afe

File tree

2 files changed

+54
-33
lines changed

2 files changed

+54
-33
lines changed

abr-testing/abr_testing/automation/jira_tool.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ def open_issue(self, issue_key: str) -> str:
107107
webbrowser.open(url)
108108
return url
109109

110+
def get_labels(self) -> List[str]:
111+
"""Get list of available labels."""
112+
url = f"{self.url}/rest/api/3/label"
113+
response = requests.request("GET", url, headers=self.headers, auth=self.auth)
114+
return response.json()
115+
110116
def create_ticket(
111117
self,
112118
summary: str,
@@ -118,18 +124,21 @@ def create_ticket(
118124
priority: str,
119125
components: list,
120126
affects_versions: str,
121-
robot: str,
127+
labels: list,
128+
parent_name: str,
122129
) -> Tuple[str, str]:
123130
"""Create ticket."""
124131
# Check if software version is a field on JIRA, if not replaces with existing version
132+
# TODO: automate parent linking
125133
data = {
126134
"fields": {
127135
"project": {"id": "10273", "key": project_key},
128136
"issuetype": {"name": issue_type},
129137
"summary": summary,
130138
"reporter": {"id": reporter_id},
131139
"assignee": {"id": assignee_id},
132-
"parent": {"key": robot},
140+
# "parent": {"key": parent_name},
141+
"labels": labels,
133142
"priority": {"name": priority},
134143
"components": [{"name": component} for component in components],
135144
"description": {
@@ -194,6 +203,7 @@ def post_attachment_to_ticket(self, issue_id: str, attachment_path: str) -> None
194203

195204
def get_project_issues(self, project_key: str) -> Dict[str, Any]:
196205
"""Retrieve all issues for the given project key."""
206+
# TODO: add field for ticket type.
197207
headers = {"Accept": "application/json"}
198208
query = {"jql": f"project={project_key}"}
199209
response = requests.request(
@@ -203,7 +213,6 @@ def get_project_issues(self, project_key: str) -> Dict[str, Any]:
203213
params=query,
204214
auth=self.auth,
205215
)
206-
response.raise_for_status()
207216
return response.json()
208217

209218
def get_project_versions(self, project_key: str) -> List[str]:

abr-testing/abr_testing/data_collection/abr_robot_error.py

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,20 @@ def compare_lpc_to_historical_data(
125125
& (df_lpc_data["Robot"] == robot)
126126
& (df_lpc_data["Module"] == labware_dict["Module"])
127127
& (df_lpc_data["Adapter"] == labware_dict["Adapter"])
128-
& (df_lpc_data["Run Ending Error"] < 1)
128+
& (df_lpc_data["Run Ending Error"])
129+
< 1
129130
]
130131
# Converts coordinates to floats and finds averages.
131-
x_float = [float(value) for value in relevant_lpc["X"]]
132-
y_float = [float(value) for value in relevant_lpc["Y"]]
133-
z_float = [float(value) for value in relevant_lpc["Z"]]
134-
current_x = round(labware_dict["X"], 2)
135-
current_y = round(labware_dict["Y"], 2)
136-
current_z = round(labware_dict["Z"], 2)
132+
try:
133+
x_float = [float(value) for value in relevant_lpc["X"]]
134+
y_float = [float(value) for value in relevant_lpc["Y"]]
135+
z_float = [float(value) for value in relevant_lpc["Z"]]
136+
current_x = round(labware_dict["X"], 2)
137+
current_y = round(labware_dict["Y"], 2)
138+
current_z = round(labware_dict["Z"], 2)
139+
except (ValueError):
140+
x_float, y_float, z_float = [0.0], [0.0], [0.0]
141+
current_x, current_y, current_z = 0.0, 0.0, 0.0
137142
try:
138143
avg_x = round(mean(x_float), 2)
139144
avg_y = round(mean(y_float), 2)
@@ -247,7 +252,7 @@ def get_error_runs_from_robot(ip: str) -> List[str]:
247252
f"http://{ip}:31950/runs", headers={"opentrons-version": "3"}
248253
)
249254
run_data = response.json()
250-
run_list = run_data["data"]
255+
run_list = run_data.get("data", [])
251256
for run in run_list:
252257
run_id = run["id"]
253258
num_of_errors = len(run["errors"])
@@ -258,7 +263,7 @@ def get_error_runs_from_robot(ip: str) -> List[str]:
258263

259264
def get_robot_state(
260265
ip: str, reported_string: str
261-
) -> Tuple[Any, Any, Any, List[str], str]:
266+
) -> Tuple[Any, Any, Any, List[str], List[str], str]:
262267
"""Get robot status in case of non run error."""
263268
description = dict()
264269
# Get instruments attached to robot
@@ -274,10 +279,11 @@ def get_robot_state(
274279
f"http://{ip}:31950/health", headers={"opentrons-version": "3"}
275280
)
276281
health_data = response.json()
277-
parent = health_data.get("name", "")
282+
print(f"health data {health_data}")
283+
robot = health_data.get("name", "")
278284
# Create summary name
279-
description["robot_name"] = parent
280-
summary = parent + "_" + reported_string
285+
description["robot_name"] = robot
286+
summary = robot + "_" + reported_string
281287
affects_version = health_data.get("api_version", "")
282288
description["affects_version"] = affects_version
283289
# Instruments Attached
@@ -297,6 +303,12 @@ def get_robot_state(
297303
description[module["moduleType"]] = module
298304
components = ["Flex-RABR"]
299305
components = match_error_to_component("RABR", reported_string, components)
306+
if "alpha" in affects_version:
307+
components.append("flex internal releases")
308+
labels = [robot]
309+
if "8.2" in affects_version:
310+
labels.append("8_2_0")
311+
parent = affects_version + " Bugs"
300312
print(components)
301313
end_time = datetime.now()
302314
print(end_time)
@@ -317,13 +329,14 @@ def get_robot_state(
317329
parent,
318330
affects_version,
319331
components,
332+
labels,
320333
whole_description_str,
321334
)
322335

323336

324337
def get_run_error_info_from_robot(
325338
ip: str, one_run: str, storage_directory: str
326-
) -> Tuple[str, str, str, List[str], str, str]:
339+
) -> Tuple[str, str, str, List[str], List[str], str, str]:
327340
"""Get error information from robot to fill out ticket."""
328341
description = dict()
329342
# get run information
@@ -339,16 +352,19 @@ def get_run_error_info_from_robot(
339352
error_code = error_dict["Error_Code"]
340353
error_instrument = error_dict["Error_Instrument"]
341354
# JIRA Ticket Fields
342-
355+
robot = results.get("robot_name", "")
343356
failure_level = "Level " + str(error_level) + " Failure"
344357

345358
components = [failure_level, "Flex-RABR"]
346359
components = match_error_to_component("RABR", str(error_type), components)
347-
print(components)
348360
affects_version = results["API_Version"]
349-
parent = results.get("robot_name", "")
350-
print(parent)
351-
summary = parent + "_" + str(one_run) + "_" + str(error_code) + "_" + error_type
361+
if "alpha" in affects_version:
362+
components.append("flex internal releases")
363+
labels = [robot]
364+
if "8.2" in affects_version:
365+
labels.append("8_2_0")
366+
parent = affects_version + " Bugs"
367+
summary = robot + "_" + str(one_run) + "_" + str(error_code) + "_" + error_type
352368
# Description of error
353369
description["protocol_name"] = results["protocol"]["metadata"].get(
354370
"protocolName", ""
@@ -430,6 +446,7 @@ def get_run_error_info_from_robot(
430446
parent,
431447
affects_version,
432448
components,
449+
labels,
433450
whole_description_str,
434451
saved_file_path,
435452
)
@@ -503,18 +520,20 @@ def get_run_error_info_from_robot(
503520
one_run = error_runs[-1] # Most recent run with error.
504521
(
505522
summary,
506-
robot,
523+
parent,
507524
affects_version,
508525
components,
526+
labels,
509527
whole_description_str,
510528
run_log_file_path,
511529
) = get_run_error_info_from_robot(ip, one_run, storage_directory)
512530
else:
513531
(
514532
summary,
515-
robot,
533+
parent,
516534
affects_version,
517535
components,
536+
labels,
518537
whole_description_str,
519538
) = get_robot_state(ip, run_or_other)
520539
# Get Calibration Data
@@ -525,16 +544,8 @@ def get_run_error_info_from_robot(
525544
print(f"Making ticket for {summary}.")
526545
# TODO: make argument or see if I can get rid of with using board_id.
527546
project_key = "RABR"
528-
print(robot)
529-
try:
530-
parent_key = project_key + "-" + robot.split("ABR")[1]
531-
except IndexError:
532-
parent_key = ""
533-
534-
# Grab all previous issues
535-
all_issues = ticket.issues_on_board(project_key)
536-
537547
# TODO: read board to see if ticket for run id already exists.
548+
all_issues = ticket.issues_on_board(project_key)
538549
# CREATE TICKET
539550
issue_key, raw_issue_url = ticket.create_ticket(
540551
summary,
@@ -546,7 +557,8 @@ def get_run_error_info_from_robot(
546557
"Medium",
547558
components,
548559
affects_version,
549-
parent_key,
560+
labels,
561+
parent,
550562
)
551563
# Link Tickets
552564
to_link = ticket.match_issues(all_issues, summary)

0 commit comments

Comments
 (0)