Skip to content

chore(api): Speed up stackup snapshot tests #18700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 23, 2025
Merged

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Jun 20, 2025

@SyntaxColoring and @mjhuff added these extremely sick snapshot tests for labware geometry. Only downside was they took forever, but they're awesome and a solid basis for confidently modifying and improving that logic in the future. By parallelizing them - which was really easy since they were already doing subprocess stuff, so there was no shared logic to break - we can cut the test execution time down to something reasonable to run in your inner loop.

Also, there's not much of a point to this being in pytest since we're not taking advantage of anything it can do while everything's in one big test (which it has to be to take advantage of the multiprocessing); so pop it out into a new little integration-testing place and make it a command-line application that can now do filtering and such.

to come out of draft

  • test that the filtering stuff works as well as it ought to
  • fix the log and stdout/stderr spam from the console
  • do something about running out of file descriptors lol

Copy link
Contributor

@mjhuff mjhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so great, thanks a lot for doing this. Kid you not, this will probably save at least 30 hours of running this locally over the next couple of months.

@@ -120,6 +120,8 @@ jobs:
run: make -C api test-cov
- name: Ensure assets build
run: make -C api sdist wheel
- name: Check labware stacking regression tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Check labware stacking regression tests
- name: Check stacking regression tests

Kind of a future proofing nit, but since we'll probably add gripper stacking tests shortly, can we rephrase this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know better, but is there a reason this testing lives here as opposed to something like api/tests/integration_testing, even if it's not managed by pytest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just nice to have everything in api/tests/ be owned by pytest so you can do py.test tests without having to play weird directory exclusion games

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth addressing now (and would probably be worth thinking through more before committing to a change), but since this is so much faster than the current version, I wonder if we can do something like just pass tuples of all the labware/adapters for all their versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we definitely should, especially with the ability to do filtering. but let's get this in first

)

print(f"Processing {robot_info}...")
executor = ProcessPoolExecutor()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is where the magic happens.

sfoster1 added 5 commits June 23, 2025 09:44
The labware stackup integration tests rule but were also very slow,
because they were running serially and there are 8,000 of them. By
making them run in parallel using
concurrent.futures.ProcessPoolExecutor, we can make it take like a
minute instead of 2 hours.
This was running under pytest but it wasn't really _using_ pytest, and
therefore didn't have the upsides like test collection and
parametrization to balance the downsides like it being annoying to add
command line flags. By making it a standalone application, we get all
that stuff.

While we're at it, refactor so it'll be easier to add new kinds of tests
that take advantage of the test spec generation and so on.
@sfoster1 sfoster1 force-pushed the speed-up-stackup-teasts branch from d4b3f06 to c42553f Compare June 23, 2025 13:45
@sfoster1 sfoster1 marked this pull request as ready for review June 23, 2025 13:46
@sfoster1 sfoster1 requested review from a team as code owners June 23, 2025 13:46
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.75%. Comparing base (981511a) to head (c42553f).
Report is 3 commits behind head on edge.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             edge   #18700   +/-   ##
=======================================
  Coverage   24.75%   24.75%           
=======================================
  Files        3284     3284           
  Lines      285464   285416   -48     
  Branches    28663    28655    -8     
=======================================
  Hits        70662    70662           
+ Misses     214781   214733   -48     
  Partials       21       21           
Flag Coverage Δ
protocol-designer 19.04% <ø> (+<0.01%) ⬆️
step-generation 5.25% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sfoster1 sfoster1 merged commit 1801cde into edge Jun 23, 2025
22 of 25 checks passed
@sfoster1 sfoster1 deleted the speed-up-stackup-teasts branch June 23, 2025 15:26
@ddcc4
Copy link
Collaborator

ddcc4 commented Jun 26, 2025

Hey, the stacking regression tests seem to take forever and then time out in CI (which makes it hard for me to get stuff merged into edge when I have to race against other people making changes).

Do you have an example of them ever completing successfully in CI? Even for this PR, they just time out after reaching

Processed 1490/7474 items. Successful: 209, Errors: 1281
Error: The operation was canceled.

https://github.com/Opentrons/opentrons/actions/runs/15826957756/job/44609936201?pr=18700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants