-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
TST: Mark slow tests in astropy/samp #16095
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
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
👋 Thank you for your draft pull request! Do you know that you can use |
I'll have to ponder later if the cost of not running this for all combo is worth the benefit. Not like we just sit staring at the CI until it finishes. |
I like this idea, but it would be good to get some input on whether these specific tests are things that are likely to fail on just one architecture. Also, some of the slowest tests may be ones that are excessively parametrized (or the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I am okay with marking SAMP as slow, but not comfortable with io.fits
and utils
. FITS is a can of worms and utils
is backbone of many things. I want them both to be tested widely. A bit of slowness in CI is a price I am willing to pay (not that we're paying, har har).
Thank you for your understanding!
@@ -204,6 +204,7 @@ def test_disable_image_compression(self): | |||
with fits.open(self.data("comp.fits")) as hdul: | |||
assert isinstance(hdul[1], fits.CompImageHDU) | |||
|
|||
@pytest.mark.slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, looking at the actual test, I think the only reason it is slow is because it sleeps for 1 second! Can we change that to 0.1 s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works on my system but I'm not sure how portable this is, maybe the test would fail on slower archs/containers/VMs ? Anyway, time.sleep(1)
is used in combinations with pytest.mark.slow
in other similar tests, but admittedly a difference is that in this one case, sleep
is actually responsible for most of the test's time, so let's try that.
astropy/io/fits/tests/test_groups.py
Outdated
@@ -48,6 +48,7 @@ def test_open(self): | |||
assert ghdu.data[0].data.shape == naxes[::-1] | |||
assert ghdu.data[0].parnames == parameters | |||
|
|||
@pytest.mark.slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the same here! It sleeps for 1 second.
astropy/io/fits/tests/test_image.py
Outdated
@@ -927,6 +927,7 @@ def test_image_update_header(self): | |||
|
|||
# The test below raised a `ResourceWarning: unclosed transport` exception | |||
# due to a bug in Python <=3.10 (cf. cpython#90476) | |||
@pytest.mark.slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note that even cutting 90% of sleep time in this test only makes it 5 times longer than the second slowest in the module. That's about 0.2s on my machine, which is probably acceptable. Let's try !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said before, I am not comfortable marking anything in io.fits
as slow here. I will defer to @saimn .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well there is no good value here, depends on the system, disk, caching etc.
So 1s is maybe a bit too much but seems reasonable to avoid wasting time debugging issues on CI or on exotic platforms.
@@ -17,6 +17,7 @@ def test_SAMPHubServer(): | |||
SAMPHubServer(web_profile=False, mode="multiple", pool_size=1) | |||
|
|||
|
|||
@pytest.mark.slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And another one that sleeps 1 sec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The very next test also combines sleep(1)
+ pytest.mark.slow
. In other tests, the file system would be the bottleneck and I think it's reasonable to assume that 1s is (too) generous, but here I'm actually not so sure: starting a server seems like a much more involved task than changing flags on a file.
astropy/utils/tests/test_console.py
Outdated
@@ -155,6 +155,7 @@ def test_progress_bar_as_generator(): | |||
assert sum == 1225 | |||
|
|||
|
|||
@pytest.mark.slow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_progress_bar_func.func also sleeps (though not as long)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, sleep
time is actually not dominant, so I think it should still be marked as slow with no other changes.
Looking through the actual tests, quite a few are slow just because they are sleeping - with 12000 tests, one really should not do even |
Over in PlasmaPy, we've started marking tests as slow if they take longer than ∼0.25–0.5 seconds. By doing that, and caching This a long way of saying...thank you for doing this! 😺 |
I like the idea of caching - thanks for linking to that example setup!! |
5fd66b3
to
6d53ac6
Compare
astropy/io/fits/tests/test_image.py
Outdated
@@ -925,9 +925,6 @@ def test_image_update_header(self): | |||
with fits.open(self.temp("test0.fits")) as hdul: | |||
assert (orig_data == hdul[1].data).all() | |||
|
|||
# The test below raised a `ResourceWarning: unclosed transport` exception | |||
# due to a bug in Python <=3.10 (cf. cpython#90476) | |||
@pytest.mark.filterwarnings("ignore:unclosed transport <asyncio.sslproto") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this cleanup is actually orthogonal, I've opened #16183 for it.
Sorry I forgot about this one for a couple weeks ! |
6d53ac6
to
93f55eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'll approve for all but utils
, deferring to @pllim for that.
astropy/utils/tests/test_data.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also not comfortable in marking utils
tests as slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Much appreciated.
93f55eb
to
40fdec3
Compare
Finally coming to this one (after catching up will the flood of notifications, taking some time off is getting harder...). Now for a run without slow tests (https://github.com/astropy/astropy/actions/runs/8011602338/job/21885207469#step:10:1717), it seems more reasonable, with only a few tests takings more than 2 sec. (on CI, which is usually much ower):
So unless we decide to skip all tests >1s or even less I would prefer to keep the 3 tests doing a sleep in |
And local results with a faster cpu:
Sure we could speedup even more by removing some tests but it seems difficult to put a limit (and what about tests that run faster but are repeated dozens of time). |
Thanks for the insight, I had no idea that 20s tests were a thing 🤯 |
40fdec3
to
0016bad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your understanding!
Description
A quick follow up to #16064
I found the 10 longest (non-slow, not parametrized) tests with
pytest astropy/ --timer-top-n 20
(withpytest-timer
), which is also about the same set of tests that takelonger than a second on my machine (supposedly a pretty fast M2).
On my install,
pytest astropy
takes about 2'15 on main, and 1'55 with this branch, hence I claim that skipping those 10 tests (out of 24k) might save about 10% CI time.