Skip to content

Commit d6a934b

Browse files
committed
analysis cli and simplified opentrons install
1 parent 2533b1b commit d6a934b

File tree

8 files changed

+1248
-128
lines changed

8 files changed

+1248
-128
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-tests

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

Lines changed: 0 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:
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: 73 additions & 10 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
@@ -134,12 +130,6 @@ CHUNK ?= chunk_0.json
134130
analyze-chunk:
135131
uv run python -m automation.analyze_from_chunk --chunk $(CHUNK)
136132

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

0 commit comments

Comments
 (0)