Skip to content

Commit

Permalink
Merge branch 'edge' into abr-plate-reader-tart
Browse files Browse the repository at this point in the history
  • Loading branch information
rclarke0 authored Nov 21, 2024
2 parents 21a4025 + a166bc3 commit d5a535e
Show file tree
Hide file tree
Showing 329 changed files with 2,185 additions and 865 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ push:
sleep 1
$(MAKE) -C $(UPDATE_SERVER_DIR) push

.PHONY: push-folder
PUSH_HELPER := abr-testing/abr_testing/tools/make_push.py
push-folder:
$(OT_PYTHON) $(PUSH_HELPER)

.PHONY: push-ot3
push-ot3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def run(
ip_json_file = os.path.join(storage_directory, "IPs.json")
try:
ip_file = json.load(open(ip_json_file))
robot_dict = ip_file.get("ip_address_list")
except FileNotFoundError:
print(f"Add .json file with robot IPs to: {storage_directory}.")
sys.exit()
Expand All @@ -294,7 +295,7 @@ def run(
ip_or_all = input("IP Address or ALL: ")
calibration_data = []
if ip_or_all.upper() == "ALL":
ip_address_list = ip_file["ip_address_list"]
ip_address_list = list(robot_dict.keys())
for ip in ip_address_list:
saved_file_path, calibration = read_robot_logs.get_calibration_offsets(
ip, storage_directory
Expand Down
3 changes: 2 additions & 1 deletion abr-testing/abr_testing/data_collection/get_run_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ def get_all_run_logs(
ip_json_file = os.path.join(storage_directory, "IPs.json")
try:
ip_file = json.load(open(ip_json_file))
robot_dict = ip_file.get("ip_address_list")
except FileNotFoundError:
print(f"Add .json file with robot IPs to: {storage_directory}.")
sys.exit()
ip_address_list = ip_file["ip_address_list"]
ip_address_list = list(robot_dict.keys())
runs_from_storage = read_robot_logs.get_run_ids_from_google_drive(google_drive)
for ip in ip_address_list:
runs = get_run_ids_from_robot(ip)
Expand Down
3 changes: 1 addition & 2 deletions abr-testing/abr_testing/protocol_simulation/abr_sim_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_files() -> Tuple[Dict[str, Dict[str, Union[str, Path]]], List[Path]]:
labware_defs = []
for root, directories, _ in os.walk(root_dir):
for directory in directories:
if directory == "active_protocols":
if directory not in exclude:
active_dir = os.path.join(root, directory)
for file in os.listdir(
active_dir
Expand Down Expand Up @@ -100,7 +100,6 @@ def get_files() -> Tuple[Dict[str, Dict[str, Union[str, Path]]], List[Path]]:
exclude = [
"__init__.py",
"helpers.py",
"shared_vars_and_funcs.py",
]
print("Simulating Protocols")
file_dict, labware_defs = get_files()
Expand Down
95 changes: 95 additions & 0 deletions abr-testing/abr_testing/tools/make_push.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""Push one or more folders to one or more robots."""
import subprocess
import multiprocessing
import json

global folders
# Opentrons folders that can be pushed to robot
folders = [
"abr-testing",
"hardware-testing",
"abr-testing + hardware-testing",
"other",
]


def push_subroutine(cmd: str) -> None:
"""Pushes specified folder to specified robot."""
try:
subprocess.run(cmd)
except Exception:
print("failed to push folder")
raise


def main(folder_to_push: str, robot_to_push: str) -> int:
"""Main process!"""
cmd = "make -C {folder} push-ot3 host={ip}"
robot_ip_path = ""
push_cmd = ""
folder_int = int(folder_to_push)
if folders[folder_int].lower() == "abr-testing + hardware-testing":
if robot_to_push.lower() == "all":
robot_ip_path = input("Path to robot ips: ")
with open(robot_ip_path, "r") as ip_file:
robot_json = json.load(ip_file)
robot_ips_dict = robot_json.get("ip_address_list")
robot_ips = list(robot_ips_dict.keys())
ip_file.close()
else:
robot_ips = [robot_to_push]
for folder_name in folders[:-2]:
# Push abr-testing and hardware-testing folders to all robots
for robot in robot_ips:
print_proc = multiprocessing.Process(
target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",)
)
print_proc.start()
print_proc.join()
push_cmd = cmd.format(folder=folder_name, ip=robot)
process = multiprocessing.Process(
target=push_subroutine, args=(push_cmd,)
)
process.start()
process.join()
print_proc = multiprocessing.Process(target=print, args=("Done!\n\n",))
print_proc.start()
print_proc.join()
else:

if folder_int == (len(folders) - 1):
folder_name = input("Which folder? ")
else:
folder_name = folders[folder_int]
if robot_to_push.lower() == "all":
robot_ip_path = input("Path to robot ips: ")
with open(robot_ip_path, "r") as ip_file:
robot_json = json.load(ip_file)
robot_ips = robot_json.get("ip_address_list")
ip_file.close()
else:
robot_ips = [robot_to_push]

# Push folder to robots
for robot in robot_ips:
print_proc = multiprocessing.Process(
target=print, args=(f"Pushing {folder_name} to {robot}!\n\n",)
)
print_proc.start()
print_proc.join()
push_cmd = cmd.format(folder=folder_name, ip=robot)
process = multiprocessing.Process(target=push_subroutine, args=(push_cmd,))
process.start()
process.join()
print_proc = multiprocessing.Process(target=print, args=("Done!\n\n",))
print_proc.start()
print_proc.join()
return 0


if __name__ == "__main__":
for i, folder in enumerate(folders):
print(f"{i}) {folder}")
folder_to_push = input("Please Select a Folder to Push: ")
robot_to_push = input("Type in robots ip (type all for all): ")
print(main(folder_to_push, robot_to_push))
52 changes: 38 additions & 14 deletions analyses-snapshot-testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ CACHEBUST ?= $(shell date +%s)
ANALYSIS_REF ?= edge
PROTOCOL_NAMES ?= all
OVERRIDE_PROTOCOL_NAMES ?= all
OPENTRONS_VERSION ?= edge
LOCAL_IMAGE_TAG ?= local
ANALYZER_IMAGE_NAME ?= opentrons-analysis

export OPENTRONS_VERSION # used for server
export ANALYSIS_REF # used for analysis and snapshot test
export PROTOCOL_NAMES # used for the snapshot test
export OVERRIDE_PROTOCOL_NAMES # used for the snapshot test
export ANALYSIS_REF # tag, branch or commit for the opentrons repository. Used as the image tag for the analyzer image
export PROTOCOL_NAMES # tell the test which protocols to run
export OVERRIDE_PROTOCOL_NAMES # tell the test which override protocols to run

ifeq ($(CI), true)
PYTHON=python
Expand Down Expand Up @@ -93,23 +93,47 @@ build-base-image:

.PHONY: build-opentrons-analysis
build-opentrons-analysis:
@echo "Building docker image for $(ANALYSIS_REF)"
@echo "The image will be named opentrons-analysis:$(ANALYSIS_REF)"
@echo "If you want to build a different version, run 'make build-opentrons-analysis ANALYSIS_REF=<version>'"
docker build --build-arg BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) --build-arg ANALYSIS_REF=$(ANALYSIS_REF) --build-arg CACHEBUST=$(CACHEBUST) -t opentrons-analysis:$(ANALYSIS_REF) -f citools/Dockerfile.analyze citools/.
@echo "Building docker image for opentrons repository reference$(ANALYSIS_REF)"
@echo "The image will be named $(ANALYZER_IMAGE_NAME):$(ANALYSIS_REF)"
@echo "If you want to build a different version, run 'make build-opentrons-analysis ANALYSIS_REF=<tag, branch, or commit>'"
docker build --build-arg BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) --build-arg ANALYSIS_REF=$(ANALYSIS_REF) --build-arg CACHEBUST=$(CACHEBUST) -t $(ANALYZER_IMAGE_NAME):$(ANALYSIS_REF) -f citools/Dockerfile.analyze citools/.

.PHONY: local-build
local-build:
.PHONY: build-local
build-local:
@echo "Building docker image for your local opentrons code"
@echo "The image will be named opentrons-analysis:local"
@echo "For a fresh build, run 'make local-build NO_CACHE=1'"
docker build --build-arg BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) $(BUILD_FLAGS) -t opentrons-analysis:local -f citools/Dockerfile.local .. || true
@echo "This image will be named $(ANALYZER_IMAGE_NAME):$(LOCAL_IMAGE_TAG)"
docker build --build-arg BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) -t $(ANALYZER_IMAGE_NAME):$(LOCAL_IMAGE_TAG) -f citools/Dockerfile.local ..
@echo "Build complete"

.PHONY: snapshot-test-local
snapshot-test-local: ANALYSIS_REF=$(LOCAL_IMAGE_TAG)
snapshot-test-local: build-base-image build-local
@echo "This target is overriding the ANALYSIS_REF to the LOCAL_IMAGE_TAG: $(LOCAL_IMAGE_TAG)"
@echo "ANALYSIS_REF is $(ANALYSIS_REF). The the test maps this env variable to the image tag."
@echo "The image the test will use is $(ANALYZER_IMAGE_NAME):$(LOCAL_IMAGE_TAG)"
@echo "PROTOCOL_NAMES is $(PROTOCOL_NAMES)"
@echo "OVERRIDE_PROTOCOL_NAMES is $(OVERRIDE_PROTOCOL_NAMES)"
$(PYTHON) -m pipenv run pytest -k analyses_snapshot_test -vv

.PHONY: snapshot-test-update-local
snapshot-test-update-local: ANALYSIS_REF=$(LOCAL_IMAGE_TAG)
snapshot-test-update-local: build-base-image build-local
@echo "This target is overriding the ANALYSIS_REF to the LOCAL_IMAGE_TAG: $(LOCAL_IMAGE_TAG)"
@echo "ANALYSIS_REF is $(ANALYSIS_REF). The the test maps this env variable to the image tag."
@echo "The image the test will use is $(ANALYZER_IMAGE_NAME):$(LOCAL_IMAGE_TAG)"
@echo "PROTOCOL_NAMES is $(PROTOCOL_NAMES)"
@echo "OVERRIDE_PROTOCOL_NAMES is $(OVERRIDE_PROTOCOL_NAMES)"
$(PYTHON) -m pipenv run pytest -k analyses_snapshot_test --snapshot-update

.PHONY: generate-protocols
generate-protocols:
$(PYTHON) -m pipenv run python -m automation.data.protocol_registry

# Tools for running the robot server in a container

OPENTRONS_VERSION ?= edge
export OPENTRONS_VERSION # used for the robot server image as the tag, branch or commit for the opentrons repository

.PHONY: build-rs
build-rs:
@echo "Building docker image for opentrons-robot-server:$(OPENTRONS_VERSION)"
Expand Down
17 changes: 12 additions & 5 deletions analyses-snapshot-testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

1. Follow the instructions in [DEV_SETUP.md](../DEV_SETUP.md)
1. `cd analyses-snapshot-testing`
1. use pyenv to install python 3.12 and set it as the local python version for this directory
1. use pyenv to install python 3.13 and set it as the local python version for this directory
1. `make setup`
1. Have docker installed and ready

Expand Down Expand Up @@ -72,10 +72,17 @@ cd analyses-snapshot-testing \

> This copies in your local code to the container and runs the analyses battery against it.

1. `make build-base-image`
1. `make build-local`
1. `make local-snapshot-test`
`cd PYENV_ROOT && git pull` - make sure pyenv is up to date so you may install python 3.13.0
`pyenv install 3.13.0` - install python 3.13.0
`cd <OPENTRONS_REPO_ROOT>/analyses-snapshot-testing` - navigate to the analyses-snapshot-testing directory
`pyenv local 3.13.0` - set the local python version to 3.13.0
`make setup` - install the requirements
`make snapshot-test-local` - this target builds the base image, builds the local code into the base image, then runs the analyses battery against the image you just created

You have the option to specify one or many protocols to run the analyses on. This is also described above [Running the tests against specific protocols](#running-the-tests-against-specific-protocols)

- `make local-snapshot-test PROTOCOL_NAMES=Flex_S_v2_19_Illumina_DNA_PCR_Free OVERRIDE_PROTOCOL_NAMES=none`
- `make snapshot-test-local PROTOCOL_NAMES=Flex_S_v2_19_Illumina_DNA_PCR_Free OVERRIDE_PROTOCOL_NAMES=none`

### Updating the snapshots locally

- `make snapshot-test-update-local` - this target builds the base image, builds the local code into the base image, then runs the analyses battery against the image you just created, updating the snapshots by passing the `--update-snapshots` flag to the test
Original file line number Diff line number Diff line change
Expand Up @@ -16668,6 +16668,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"apiLevel": "2.11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41584,6 +41584,7 @@
"location": "offDeck"
}
],
"liquidClasses": [],
"liquids": [
{
"description": "Bacterial culture medium (e.g., LB broth)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4919,6 +4919,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"apiLevel": "2.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11824,6 +11824,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"author": "<[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11452,6 +11452,7 @@
}
}
],
"liquidClasses": [],
"liquids": [
{
"description": "High Quality H₂O",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2917,6 +2917,7 @@
}
}
],
"liquidClasses": [],
"liquids": [
{
"description": "H₂O",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3113,6 +3113,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"author": "Opentrons Engineering <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9569,6 +9569,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"author": "Opentrons Engineering <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66156,6 +66156,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"author": "Opentrons <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"description": "oooo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {},
"modules": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49707,6 +49707,7 @@
}
}
],
"liquidClasses": [],
"liquids": [
{
"description": "CleanupBead Beads",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
}
],
"labware": [],
"liquidClasses": [],
"liquids": [],
"metadata": {
"protocolName": "Description Too Long 2.18"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"description": "oooo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17072,6 +17072,7 @@
}
}
],
"liquidClasses": [],
"liquids": [
{
"description": "H₂O",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9569,6 +9569,7 @@
}
}
],
"liquidClasses": [],
"liquids": [],
"metadata": {
"author": "Opentrons Engineering <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49392,6 +49392,7 @@
}
}
],
"liquidClasses": [],
"liquids": [
{
"description": "Beads",
Expand Down
Loading

0 comments on commit d5a535e

Please sign in to comment.