-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Do not include tests in Astropy wheels (reduce wheel size for AWS Lambda) #16152
Comments
It would be useful to compare these numbers against the size of astropy's dependencies in the same context. |
By far the largest dependency of Astropy is Numpy, which on Linux aarch64 takes up 63 MB. Of that, 15 MB is tests and test data. |
Packaging for AWS is painful. When I had to do this once for a temporary project, I had to strip docs, tests, and some unused sub-packages out to get it to stay in budget. But by doing this for AWS, the cost is that user will no longer be able to test their installation. That cost is quite high. Maybe we can discuss this at the Coordination Meeting? 🤔 Or at least bring it up at the next dev telecon? 🤔 |
Sure... I have been out of the loop of dev telecons. When are they? |
Next dev-telecon is this Thursday: https://docs.google.com/document/d/15JSFh3OMF9Iz6ov3q_xxGO_BL8hRnuse4IMUrqEIvcg/edit#heading=h.ntv4vdb5izj7 |
I can't make it to this Thursday, but I can try for the next one. |
I'd be curious how often this is used. At the start of the project, before we had any proper or limited CI, it was one of the main ways we found out about platform-specific issues, but with such extensive CI coverage now, do any users installing wheels for example ever run |
If users really do want the ability to test their installation we could look into packaging the tests into a separate package, say |
+1 with @astrofrog (Just thinking out loud here) I think many packages in the scientific python ecosystem had this in built testing due to limited CI + a need to build packages during pip install in the good ol days. With wheels today I wonder how many users would need to worry about installing a wheel and then the wheel failing the tests (we should be able to catch that quickly in our CI!). And for the user group who want to build and test I think it's fair to ask them to clone the repo/tag directly from GitHub. |
Now it is starting to sound like y'all wanna kill the test runner altogether! Line 137 in d32a06a
Perhaps it is time (see #16165) but this is a long standing public API. Additionally we also encouraged downstream packages to ship their own |
My inclination would be to include tests, etc. in the source distribution (sdist) but not include tests in wheels. I looked into this a little bit and I think we could do this by including tests in from setuptools import setup, find_packages
setup(..., packages=find_packages(exclude=["tests"])) |
That or revive the controversial discussion to move tests outside of |
Good point, that would also work! And that seems to be the packaging trend these years, with Turns out there was a lot of discussion about dropping tests from wheels in pandas in the last few years, again motivated by AWS: pandas-dev/pandas#30741 |
Ah, right, the Well, if |
That's what I've been doing for a while and it's great. The only inconvenience is you can't run the tests from the REPL, but I haven't actually done that even with Astropy for years, so it was no great loss.
I think we can do it! |
As I recall, the primary motivation for having the tests in the wheels/installed version is that a user who wants to do release candidate testing is often not going to bother grabbing the source, but they will run the tests if its packaged with the code. This certainly happens in release candidates, whenever anyone tests it locally. I don't see that that has changed. So it's now a question if that's more important than the cloud packaging issues (which I relate to, as I've had exactly the same lambda pain @lpsinger pointed out!) That said, I think there's a couple of alternatives to consider:
I think 3 is the easiest and cleanest, personally, if our motivation is basically "for the cloud" since cloud is container-dominated anyway. |
@saimn pointed out there is related discussions about wheel size at https://astropy.slack.com/archives/C7D5BPFJR/p1680076057936899 |
Ole replied here: #16165 (comment) (sorry I didn't get a chance to cross-post before the dev telecon) In Debian, we use pytest only (specifically |
Putting on my Debian hat (which I imagine is a liberty cap), @olebole may have been referring to autopkgtest. Autopkgtests are run against installed packages to check that they have not regressed (e.g. due to changes in other packages). It is certainly very simple to write autopkgtests when the tests are actually installed. However, "The cwd of each test is guaranteed to be the root of the source package, which will have been unpacked but not built." (See autopkgtest spec.) So including the tests in the source distribution (or even just in the git repository, as many Debian source packages these days are derived from upstream's git repo) but not the installation would also be fine for autopkgtest. |
In Debian, we have two types of tests: First during the build (which is often a bit fiddly because the test runs on the built, but not installed, package). And we have "CI tests", which run on the installed package. The command for Astropy is
For the installed package however, we still have the sources so that we can access test data etc. if required. |
This is reminding me of |
Update: Killing the test runner is now its own separate issue. |
But nobody actually does this. If people do The only people who run tests are developers, who already have the git repo with the tests and test data, and maybe a first time user who is reading through the docs of installing astropy for the first time, and uses the test runner after pip installing because the docs tell them to do so. How about we stop telling people to do that, and like every other well-tested package out there, just ship it and rely on CI to make sure it works on supported platforms. Users should not run the test suite as a matter of course unless there's a serious problem that needs debugging, and at that point they file an issue or have the git repo to poke around in themselves. And of course we should also move the tests outside of a And deprecate the test runner. 🔥 |
Strong argument there. And concise. I have no objection, your honor. 😆 |
So, to recap what I think came out of the dev telecon on 2024-03-07, there are several options:
2.5. (See astrofrog comment below.) Less of Most Impact: We go all in with src layout (#13678) and getting rid of astropy.test() but not the test runner. Major change to code base (plus all the open PRs will be affected, doc overhaul, etc). Tech debt exorcised here but not downstream. Wheels naturally will no longer have tests. This will take weeks/months.
Or some combo of the above, like we give you a stop gap script from Step 1 until we can execute Step 3. Though if you already have a way to strip out tests yourselves, Step 1 is probably unnecessary. |
@lpsinger , given you were not able to attend the dev telecon on 2024-03-07, we have encouraged people to comment on the issue(s) and we will discuss again when you are able to attend next time. Thanks for your patience! |
Just a quick note on option 3 - the test runner class that downstream packages use to expose package.test() could technically be kept for a long time if we wanted to keep supporting downstream packages, long after we stop using it in astropy core itself. We don't even have to deprecate it yet. Removing astropy.test() in astropy itself is not really a significant API change in that it is unlikely many people (besides a few developers in the project) use it as part of scripts/programs. |
So is the following a good interpretation of your suggestion in #16152 (comment) ? 2.5. Less of Most Impact: We go all in with |
Yep! |
I'd vote for option (2), as I think it makes sense not to include tests, and think it is OK to remove use of I don't see the connection with I feel a bit like a broken record, but really wish we could focus more on improving astropy in ways that a user might actually notice; there is very little joy in reviewing yet another PR that enforces some other ruff rule, especially if done by a first-time contributor who doesn't have the knowledge to see the pitfalls. |
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
This reduces the size of the installation by a few MB, making Healpy a little bit more cloud-friendly. See astropy/astropy#16152.
What is the problem this feature will solve?
Astropy is a very heavyweight dependency and is difficult to use in a serverless, space-constrained environment like AWS Lambda. When installed from wheels for Linux aarch64, the
astropy
directory insite-packages
takes up 58 MB. Of that, theastropy/**/tests
directories take up 20 MB.Describe the desired outcome
Move the test directories out of the installed Python package, or exclude them from packaging.
Additional context
No response
The text was updated successfully, but these errors were encountered: