Skip to content

Commit cff1817

Browse files
authored
feat(analyses-snapshot-testing): add cli and cleaner opentrons installation (#19068)
1 parent 88cc4c4 commit cff1817

File tree

10 files changed

+1261
-132
lines changed

10 files changed

+1261
-132
lines changed

.github/workflows/analyses-snapshot-lint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jobs:
3535
- name: ruff-check
3636
working-directory: ./analyses-snapshot-testing
3737
run: make ruff-check
38+
- name: unit tests
39+
working-directory: ./analyses-snapshot-testing
40+
run: make unit-test

.github/workflows/analyses-snapshot-test.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ jobs:
105105
- name: Sync the project
106106
working-directory: ./analyses-snapshot-testing
107107
run: make ci-setup
108-
- name: Install Opentrons
109-
working-directory: ./analyses-snapshot-testing
110-
run: make install-ot
111108
- uses: actions/download-artifact@v4
112109
with:
113110
name: chunks
@@ -145,9 +142,6 @@ jobs:
145142
- name: Sync the project
146143
working-directory: ./analyses-snapshot-testing
147144
run: make ci-setup
148-
- name: Install Opentrons
149-
working-directory: ./analyses-snapshot-testing
150-
run: make install-ot
151145
- name: Download All Analysis Results
152146
uses: actions/download-artifact@v4
153147
with:
@@ -191,6 +185,8 @@ jobs:
191185
body: 'This PR was requested on the PR https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
192186
branch: 'analyses-snapshot-testing/heal-${{ github.event.pull_request.head.ref }}'
193187
base: ${{ github.event.pull_request.head.ref }}
188+
add-paths: |
189+
analyses-snapshot-testing/tests/__snapshots__/analyses_snapshot_test/
194190
195191
- name: Comment on feature PR
196192
if: always() && steps.create_pull_request.outcome == 'success' && github.event_name == 'pull_request'
@@ -214,3 +210,5 @@ jobs:
214210
body: 'The edge overnight analyses snapshot test is failing. This PR was opened to alert us to the failure.'
215211
branch: 'analyses-snapshot-testing/heal-edge'
216212
base: edge
213+
add-paths: |
214+
analyses-snapshot-testing/tests/__snapshots__/analyses_snapshot_test/

analyses-snapshot-testing/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.env
22
results
3+
analysis_results/**/*
34
analysis_results/*.json
5+
!analysis_results/.keepme
6+
temp_sample_protocols/**/*
7+
temp_single_protocol/**/*
48
files/protocols/generated_protocols/*
59
!files/protocols/generated_protocols/.keepme
610
chunks/*.json

analyses-snapshot-testing/Makefile

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ format:
2727
@echo "Formatting the readme with yarn prettier"
2828
$(MAKE) format-readme
2929

30-
.PHONY: test-ci
31-
test-ci:
32-
$uv run python -m pytest -m "emulated_alpha"
33-
3430
.PHONY: audit
3531
audit:
3632
uv run python -m automation.audit_snapshots
@@ -41,7 +37,13 @@ test-protocol-analysis:
4137

4238
.PHONY: ci-setup
4339
ci-setup:
44-
uv sync --locked --all-extras
40+
@echo "Setting up CI environment with editable installs..."
41+
@if uv sync --locked --all-extras 2>/dev/null; then \
42+
echo "Lockfile is current, using locked dependencies"; \
43+
else \
44+
echo "Lockfile needs update due to editable installs, syncing without lock"; \
45+
uv sync --all-extras; \
46+
fi
4547

4648
.PHONY: setup
4749
setup:
@@ -134,12 +136,6 @@ CHUNK ?= chunk_0.json
134136
analyze-chunk:
135137
uv run python -m automation.analyze_from_chunk --chunk $(CHUNK)
136138

137-
.PHONY: install-ot
138-
install-ot:
139-
@echo "Installing the opentrons package from the local codebase"
140-
uv pip install -e ../shared-data
141-
uv pip install -e ../api
142-
143139
.PHONY: create-pl-protocols
144140
create-pl-protocols:
145141
uv run python -m automation.data.create_pl_protocols
@@ -198,3 +194,76 @@ build-opentrons-analysis-%:
198194
.PHONY: unit-test
199195
unit-test:
200196
uv run python -m pytest -m "unit" -vv
197+
198+
# CLI analysis targets
199+
OUTPUT_DIR ?= analysis_results
200+
PROTOCOLS_DIR ?= files/protocols
201+
LABWARE_DIR ?= files/labware
202+
TEMP_SINGLE_DIR ?= temp_single_protocol
203+
TEMP_SAMPLE_DIR ?= temp_sample_protocols
204+
CLI_MODULE ?= automation.protocol_analysis_cli
205+
206+
SINGLE_OUTPUT_SUBDIR ?= single
207+
SAMPLE_OUTPUT_SUBDIR ?= sample
208+
SAMPLE_PATTERN ?= *Simple*
209+
SAMPLE_LIMIT ?= 5
210+
211+
.PHONY: cli-dry-run
212+
cli-dry-run: cli-clean
213+
@echo "Running Protocol Analysis CLI in dry-run mode"
214+
@echo "Protocols directory: $(PROTOCOLS_DIR)"
215+
@echo "Output directory: $(OUTPUT_DIR)"
216+
uv run python -m $(CLI_MODULE) \
217+
--protocols-dir $(PROTOCOLS_DIR) \
218+
--output-dir $(OUTPUT_DIR) \
219+
--labware-dir $(LABWARE_DIR) \
220+
--dry-run
221+
222+
.PHONY: cli-analyze-single
223+
cli-analyze-single: cli-clean
224+
ifndef PROTOCOL
225+
@echo "Error: PROTOCOL variable must be set"
226+
@echo "Usage: make cli-analyze-single PROTOCOL=$(PROTOCOLS_DIR)/your_protocol.py"
227+
@exit 1
228+
endif
229+
@echo "Running Protocol Analysis CLI on single protocol: $(PROTOCOL)"
230+
@mkdir -p $(TEMP_SINGLE_DIR)
231+
@cp $(PROTOCOL) $(TEMP_SINGLE_DIR)/
232+
uv run python -m $(CLI_MODULE) \
233+
--protocols-dir $(TEMP_SINGLE_DIR) \
234+
--output-dir $(OUTPUT_DIR)/$(SINGLE_OUTPUT_SUBDIR) \
235+
--labware-dir $(LABWARE_DIR) \
236+
--verbose
237+
@rm -rf $(TEMP_SINGLE_DIR)
238+
239+
.PHONY: cli-analyze-sample
240+
cli-analyze-sample: cli-clean
241+
@echo "Running Protocol Analysis CLI on a small sample of protocols"
242+
@mkdir -p $(TEMP_SAMPLE_DIR)
243+
@find $(PROTOCOLS_DIR) -name "$(SAMPLE_PATTERN)" -type f \( -name "*.py" -o -name "*.json" \) | head -$(SAMPLE_LIMIT) | xargs -I {} cp {} $(TEMP_SAMPLE_DIR)/
244+
@echo "Found $$(ls $(TEMP_SAMPLE_DIR)/ | wc -l) sample protocols"
245+
uv run python -m $(CLI_MODULE) \
246+
--protocols-dir $(TEMP_SAMPLE_DIR) \
247+
--output-dir $(OUTPUT_DIR)/$(SAMPLE_OUTPUT_SUBDIR) \
248+
--labware-dir $(LABWARE_DIR) \
249+
--verbose
250+
@rm -rf $(TEMP_SAMPLE_DIR)
251+
252+
.PHONY: cli-clean
253+
cli-clean:
254+
@echo "Cleaning CLI analysis results"
255+
@if [ -d "$(OUTPUT_DIR)" ]; then \
256+
find $(OUTPUT_DIR) -name "*.json" -delete; \
257+
find $(OUTPUT_DIR) -type d -empty -not -path $(OUTPUT_DIR) -delete; \
258+
echo "Cleaned analysis JSON files from $(OUTPUT_DIR) (keeping .keep-me files)"; \
259+
else \
260+
echo "No $(OUTPUT_DIR) directory found"; \
261+
fi
262+
@rm -rf $(TEMP_SAMPLE_DIR) $(TEMP_SINGLE_DIR)
263+
@echo "Cleaned temporary directories"
264+
265+
# Interactive CLI target
266+
.PHONY: cli-interactive
267+
cli-interactive: cli-clean
268+
@echo "Starting interactive protocol analysis CLI..."
269+
uv run python -m $(CLI_MODULE) --interactive

analyses-snapshot-testing/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
1. Follow the instructions in [DEV_SETUP.md](../DEV_SETUP.md) for javascript
66
1. `cd analyses-snapshot-testing`
77
1. have uv installed
8-
1. `make setup install-ot`
9-
1. Have docker installed and the daemon running
8+
1. `make setup`
109

1110
## Concepts
1211

0 commit comments

Comments
 (0)