Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Nov 25, 2024
2 parents 13b38f8 + 2dc3e1d commit b551782
Show file tree
Hide file tree
Showing 254 changed files with 5,449 additions and 2,277 deletions.
15 changes: 12 additions & 3 deletions abr-testing/abr_testing/automation/jira_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def open_issue(self, issue_key: str) -> str:
webbrowser.open(url)
return url

def get_labels(self) -> List[str]:
"""Get list of available labels."""
url = f"{self.url}/rest/api/3/label"
response = requests.request("GET", url, headers=self.headers, auth=self.auth)
return response.json()

def create_ticket(
self,
summary: str,
Expand All @@ -118,18 +124,21 @@ def create_ticket(
priority: str,
components: list,
affects_versions: str,
robot: str,
labels: list,
parent_name: str,
) -> Tuple[str, str]:
"""Create ticket."""
# Check if software version is a field on JIRA, if not replaces with existing version
# TODO: automate parent linking
data = {
"fields": {
"project": {"id": "10273", "key": project_key},
"issuetype": {"name": issue_type},
"summary": summary,
"reporter": {"id": reporter_id},
"assignee": {"id": assignee_id},
"parent": {"key": robot},
# "parent": {"key": parent_name},
"labels": labels,
"priority": {"name": priority},
"components": [{"name": component} for component in components],
"description": {
Expand Down Expand Up @@ -194,6 +203,7 @@ def post_attachment_to_ticket(self, issue_id: str, attachment_path: str) -> None

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

def get_project_versions(self, project_key: str) -> List[str]:
Expand Down
72 changes: 42 additions & 30 deletions abr-testing/abr_testing/data_collection/abr_robot_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,20 @@ def compare_lpc_to_historical_data(
& (df_lpc_data["Robot"] == robot)
& (df_lpc_data["Module"] == labware_dict["Module"])
& (df_lpc_data["Adapter"] == labware_dict["Adapter"])
& (df_lpc_data["Run Ending Error"] < 1)
& (df_lpc_data["Run Ending Error"])
< 1
]
# Converts coordinates to floats and finds averages.
x_float = [float(value) for value in relevant_lpc["X"]]
y_float = [float(value) for value in relevant_lpc["Y"]]
z_float = [float(value) for value in relevant_lpc["Z"]]
current_x = round(labware_dict["X"], 2)
current_y = round(labware_dict["Y"], 2)
current_z = round(labware_dict["Z"], 2)
try:
x_float = [float(value) for value in relevant_lpc["X"]]
y_float = [float(value) for value in relevant_lpc["Y"]]
z_float = [float(value) for value in relevant_lpc["Z"]]
current_x = round(labware_dict["X"], 2)
current_y = round(labware_dict["Y"], 2)
current_z = round(labware_dict["Z"], 2)
except (ValueError):
x_float, y_float, z_float = [0.0], [0.0], [0.0]
current_x, current_y, current_z = 0.0, 0.0, 0.0
try:
avg_x = round(mean(x_float), 2)
avg_y = round(mean(y_float), 2)
Expand Down Expand Up @@ -247,7 +252,7 @@ def get_error_runs_from_robot(ip: str) -> List[str]:
f"http://{ip}:31950/runs", headers={"opentrons-version": "3"}
)
run_data = response.json()
run_list = run_data["data"]
run_list = run_data.get("data", [])
for run in run_list:
run_id = run["id"]
num_of_errors = len(run["errors"])
Expand All @@ -258,7 +263,7 @@ def get_error_runs_from_robot(ip: str) -> List[str]:

def get_robot_state(
ip: str, reported_string: str
) -> Tuple[Any, Any, Any, List[str], str]:
) -> Tuple[Any, Any, Any, List[str], List[str], str]:
"""Get robot status in case of non run error."""
description = dict()
# Get instruments attached to robot
Expand All @@ -274,10 +279,11 @@ def get_robot_state(
f"http://{ip}:31950/health", headers={"opentrons-version": "3"}
)
health_data = response.json()
parent = health_data.get("name", "")
print(f"health data {health_data}")
robot = health_data.get("name", "")
# Create summary name
description["robot_name"] = parent
summary = parent + "_" + reported_string
description["robot_name"] = robot
summary = robot + "_" + reported_string
affects_version = health_data.get("api_version", "")
description["affects_version"] = affects_version
# Instruments Attached
Expand All @@ -297,6 +303,12 @@ def get_robot_state(
description[module["moduleType"]] = module
components = ["Flex-RABR"]
components = match_error_to_component("RABR", reported_string, components)
if "alpha" in affects_version:
components.append("flex internal releases")
labels = [robot]
if "8.2" in affects_version:
labels.append("8_2_0")
parent = affects_version + " Bugs"
print(components)
end_time = datetime.now()
print(end_time)
Expand All @@ -317,13 +329,14 @@ def get_robot_state(
parent,
affects_version,
components,
labels,
whole_description_str,
)


def get_run_error_info_from_robot(
ip: str, one_run: str, storage_directory: str
) -> Tuple[str, str, str, List[str], str, str]:
) -> Tuple[str, str, str, List[str], List[str], str, str]:
"""Get error information from robot to fill out ticket."""
description = dict()
# get run information
Expand All @@ -339,16 +352,19 @@ def get_run_error_info_from_robot(
error_code = error_dict["Error_Code"]
error_instrument = error_dict["Error_Instrument"]
# JIRA Ticket Fields

robot = results.get("robot_name", "")
failure_level = "Level " + str(error_level) + " Failure"

components = [failure_level, "Flex-RABR"]
components = match_error_to_component("RABR", str(error_type), components)
print(components)
affects_version = results["API_Version"]
parent = results.get("robot_name", "")
print(parent)
summary = parent + "_" + str(one_run) + "_" + str(error_code) + "_" + error_type
if "alpha" in affects_version:
components.append("flex internal releases")
labels = [robot]
if "8.2" in affects_version:
labels.append("8_2_0")
parent = affects_version + " Bugs"
summary = robot + "_" + str(one_run) + "_" + str(error_code) + "_" + error_type
# Description of error
description["protocol_name"] = results["protocol"]["metadata"].get(
"protocolName", ""
Expand Down Expand Up @@ -430,6 +446,7 @@ def get_run_error_info_from_robot(
parent,
affects_version,
components,
labels,
whole_description_str,
saved_file_path,
)
Expand Down Expand Up @@ -503,18 +520,20 @@ def get_run_error_info_from_robot(
one_run = error_runs[-1] # Most recent run with error.
(
summary,
robot,
parent,
affects_version,
components,
labels,
whole_description_str,
run_log_file_path,
) = get_run_error_info_from_robot(ip, one_run, storage_directory)
else:
(
summary,
robot,
parent,
affects_version,
components,
labels,
whole_description_str,
) = get_robot_state(ip, run_or_other)
# Get Calibration Data
Expand All @@ -525,16 +544,8 @@ def get_run_error_info_from_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"
print(robot)
try:
parent_key = project_key + "-" + robot.split("ABR")[1]
except IndexError:
parent_key = ""

# Grab all previous issues
all_issues = ticket.issues_on_board(project_key)

# TODO: read board to see if ticket for run id already exists.
all_issues = ticket.issues_on_board(project_key)
# CREATE TICKET
issue_key, raw_issue_url = ticket.create_ticket(
summary,
Expand All @@ -546,7 +557,8 @@ def get_run_error_info_from_robot(
"Medium",
components,
affects_version,
parent_key,
labels,
parent,
)
# Link Tickets
to_link = ticket.match_issues(all_issues, summary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,94 @@


def add_parameters(parameters: ParameterContext) -> None:
"""Parameters."""
helpers.create_single_pipette_mount_parameter(parameters)
"""Add parameters."""
parameters.add_int(
variable_name="number_of_plates",
display_name="Number of Plates",
default=4,
minimum=1,
maximum=4,
)


def run(ctx: ProtocolContext) -> None:
"""Protocol."""
mount_pos_50ul = ctx.params.pipette_mount # type: ignore[attr-defined]
number_of_plates = ctx.params.number_of_plates # type: ignore [attr-defined]
# Plate Reader
plate_reader: AbsorbanceReaderContext = ctx.load_module(
helpers.abs_mod_str, "A3"
) # type: ignore[assignment]
hs: HeaterShakerContext = ctx.load_module(helpers.hs_str, "A1") # type: ignore[assignment]
hs_adapter = hs.load_adapter("opentrons_96_pcr_adapter")
hs_adapter = hs.load_adapter("opentrons_universal_flat_adapter")
tube_rack = ctx.load_labware(
"opentrons_10_tuberack_nest_4x50ml_6x15ml_conical", "C2", "Reagent Tube"
)
tartrazine_tube = tube_rack["A3"]

water_tube_1 = tube_rack["A4"]
water_tube_2 = tube_rack["B3"]
sample_plate_1 = ctx.load_labware(
"nest_96_wellplate_200ul_flat", "D1", "Sample Plate 1"
"corning_96_wellplate_360ul_flat", "D1", "Sample Plate 1"
)
sample_plate_2 = ctx.load_labware(
"nest_96_wellplate_200ul_flat", "C1", "Sample Plate 2"
"corning_96_wellplate_360ul_flat", "D2", "Sample Plate 2"
)
sample_plate_3 = ctx.load_labware(
"nest_96_wellplate_200ul_flat", "B1", "Sample Plate 3"
"corning_96_wellplate_360ul_flat", "C1", "Sample Plate 3"
)
sample_plate_4 = ctx.load_labware(
"corning_96_wellplate_360ul_flat", "B1", "Sample Plate 4"
)
sample_plate_list = [sample_plate_1, sample_plate_2, sample_plate_3]

sample_plate_list = [sample_plate_1, sample_plate_2, sample_plate_3, sample_plate_4]
tiprack_50_1 = ctx.load_labware("opentrons_flex_96_tiprack_50ul", "D3")
tiprack_50_2 = ctx.load_labware("opentrons_flex_96_tiprack_50ul", "C3")
tiprack_50_3 = ctx.load_labware("opentrons_flex_96_tiprack_50ul", "B3")
tiprack_1000_1 = ctx.load_labware("opentrons_flex_96_tiprack_1000ul", "A2")
tip_racks = [tiprack_50_1, tiprack_50_2, tiprack_50_3]

# Pipette
p50 = ctx.load_instrument("flex_1channel_50", mount_pos_50ul, tip_racks=tip_racks)
p50 = ctx.load_instrument("flex_1channel_50", "left", tip_racks=tip_racks)
p1000 = ctx.load_instrument(
"flex_1channel_1000", "right", tip_racks=[tiprack_1000_1]
)

# Probe wells
liquid_vols_and_wells: Dict[str, List[Dict[str, Well | List[Well] | float]]] = {
"Tartrazine": [{"well": tartrazine_tube, "volume": 45.0}]
"Tartrazine": [{"well": tartrazine_tube, "volume": 45.0}],
"Water": [{"well": [water_tube_1, water_tube_2], "volume": 45.0}],
}
helpers.find_liquid_height_of_loaded_liquids(ctx, liquid_vols_and_wells, p50)

i = 0
all_percent_error_dict = {}
cv_dict = {}
for sample_plate in sample_plate_list:
deck_locations = ["D1", "C1", "B1"]
vol = 0.0
tip_count = 0
for sample_plate in sample_plate_list[:number_of_plates]:
deck_locations = ["D1", "D2", "C1", "B1"]
p1000.pick_up_tip()
for well in sample_plate.wells():
if vol < 45000:
tube_of_choice = water_tube_1
else:
tube_of_choice = water_tube_2
p50.pick_up_tip()
p1000.aspirate(190, tube_of_choice)
p1000.air_gap(5)
p1000.dispense(5, well.top())
p1000.dispense(190, well)
vol += 190
height = helpers.find_liquid_height(p50, tartrazine_tube)
p50.aspirate(10, tartrazine_tube.bottom(z=height))
p50.air_gap(5)
p50.dispense(5, well.top())
p50.dispense(10, well.bottom(z=0.5))
p50.blow_out()
p50.return_tip()
tip_count += 1
if tip_count >= (96 * 3):
p50.reset_tipracks()
p1000.return_tip()
helpers.move_labware_to_hs(ctx, sample_plate, hs, hs_adapter)
helpers.set_hs_speed(ctx, hs, 1500, 2.0, True)
hs.open_labware_latch()
Expand Down Expand Up @@ -117,7 +149,6 @@ def run(ctx: ProtocolContext) -> None:
plate_reader.open_lid()
ctx.move_labware(sample_plate, deck_locations[i], use_gripper=True)
i += 1

# Print percent error dictionary
ctx.comment("Percent Error: " + str(all_percent_error_dict))
# Print cv dictionary
Expand Down
25 changes: 0 additions & 25 deletions abr-testing/abr_testing/protocols/csv_parameters/3_samplevols.csv

This file was deleted.

Loading

0 comments on commit b551782

Please sign in to comment.