Skip to content

Skip slow test configurations for slow tests #463

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 8 commits into from
Nov 3, 2023

Conversation

mpharrigan
Copy link
Collaborator

@mpharrigan mpharrigan commented Oct 27, 2023

xref #114

This is about 47 seconds worth of tests

@tanujkhattar
Copy link
Collaborator

To be sure, these tests can still be run if we provide a flag like --enable-slow ?

There's a parallel effort happening in Cirq to solve this problem where we can mark tests as "slow" and they'll be run only as part of daily / weekly CI instead of running them on every PR.

See quantumlib/Cirq#6211 and quantumlib/Cirq#6328

@mpharrigan
Copy link
Collaborator Author

This PR doesn't respond to flags; it just skips one of the configurations. You can run it by commenting out the skip which honestly is as good as a command line flag because I would bet most of the slow tests in projects with an --enable-slow flag rarely get executed

@tanujkhattar
Copy link
Collaborator

I would bet most of the slow tests in projects with an --enable-slow flag rarely get executed

The way it's handled in Cirq is that the slow tests get executed once as part of the daily CI while the rest of the tests get executed as part of every PR. I think this model is more robust and should be adopted. The reason slow tests exist is because we have found implementation bugs in the past which were not caught by small test cases, and having the daily CI running these slow tests will help us catch such bugs in case we change the implementation. The "run it by commenting out the skip" is not nearly as robust. Also, the infrastructure to add the daily CI and mark tests as slow is not terribly complicated and already exists in Cirq now; thanks to @pavoljuhas; so we can leverage the knowledge we've gained by implementing it in Cirq to simply adopt the same infrastructure here as well.

@mpharrigan
Copy link
Collaborator Author

Ok, let's merge this until the nightly CI is set up

@pavoljuhas
Copy link
Contributor

@mpharrigan - I think it would be better to apply the skip mark at the test function definition rather than in its body.
If it is OK, I can add a commit to this PR to do so.

@mpharrigan
Copy link
Collaborator Author

These are parameterized tests using the "outer product" over the two parameter sets. Most of the parameter settings are not slow; just the cases identified by the if ... skip are slow.

@pavoljuhas
Copy link
Contributor

Yes, I add a skip for the same tests in quantumlib/Cirq#6211.
I have refactored double parametrization to a single one, it should be easy to cherry-pick that change here.

@mpharrigan
Copy link
Collaborator Author

Got it, cool!

@pavoljuhas
Copy link
Contributor

Got it, cool!

Done in 66af330...d783c51

"data", [[[1, 2, 3, 4, 5]], [[1, 2, 3], [4, 5, 10]], [[1], [2], [3], [4], [5], [6]]]
"data,num_controls",
[
pytest.param(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a really nice thing to know about, thanks @pavoljuhas !

Comment on lines 45 to 46
if num_controls == 2 and len(data) == 6:
pytest.skip("slow")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this should be removed now, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh I see two of them you skip in the decorator and this one you mark as slow and skip in the body. Is this to show how to do it when we set up a "slow" marker?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be removed now, right?

Correct, done in 6d6d3ff.

Is this to show how to do it when we set up a "slow" marker?

Sorry about that, I got it confused at a late hour. Fixed at ab84a43.
The mark should be mark.skip("slow"); we don't have a slow marker defined yet.

@mpharrigan
Copy link
Collaborator Author

The problem is we don't actually use or respect the slow marker

@pavoljuhas
Copy link
Contributor

The problem is we don't actually use or respect the slow marker

Yes, thank you for catching that. I overlooked the mark after a copy-paste from Cirq.

We can setup a slow marker with its own test skipping logic like in Cirq, but that is a thing for a next PR.

@mpharrigan
Copy link
Collaborator Author

I opened #491 to track

@mpharrigan mpharrigan enabled auto-merge (squash) November 3, 2023 23:16
@mpharrigan mpharrigan merged commit 3edc1ae into main Nov 3, 2023
@mpharrigan mpharrigan deleted the 2023-10-skip-slow-tests branch January 19, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants