Fix configuring astropy cache location#17514
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.
|
mhvk
left a comment
There was a problem hiding this comment.
Looks good to me, thanks @eerovaher!
| if ( | ||
| (xdg_config_home := os.getenv("XDG_CONFIG_HOME")) is not None | ||
| and (xch := Path(xdg_config_home)).exists() | ||
| (xdg_dir := os.getenv(f"XDG_{fallback.upper()}_HOME")) is not None |
There was a problem hiding this comment.
Might be useful to specify above that fallback can take a limited number of values.
There was a problem hiding this comment.
yes. We could also expose the environment variable directly as a separate argument, since it's a private function, there's no pressure to preserve its API.
There was a problem hiding this comment.
Might be useful to specify above that
fallbackcan take a limited number of values.
A good way to do that would be to change the type annotation of the fallback parameter from str to Literal["cache", "config"], but it would also be a good idea to update the annotation of the cls parameter from type to type[_SetTempPath] and there is more room for improvement elsewhere in this file. My preference would be to only make minimal required changes here to fix the bug and to open a separate pull request for the annotations.
There was a problem hiding this comment.
Sounds like a plan to me. Final question before I merge: do you want to do the follow up yourself too ? (either way is fine)
There was a problem hiding this comment.
I wouldn't mind updating the annotations myself.
|
I've figured out why the double test CI job failed, but I don't have a good solution how to get it to work. The double test job uses the Line 125 in 2e7cf84 The astropy test runner configures the cache directory using set_temp_cache(): astropy/astropy/tests/runner.py Line 253 in 2e7cf84 set_temp_cache() is supposed to have priority over environment variables, which fully explains why changing the environment variables in the new test has no effect in that one CI job.
The best solution would be to skip the new test if and only if the tests are run using the |
One more data point in favor of killing the test runner, but as long as we agree to live with it, this might be the only way out. |
pllim
left a comment
There was a problem hiding this comment.
Good catch. Thanks!
Original config designer was probably mdboom who left some time ago. 🙈
|
Your tests seem to fail in the "double" run, so that needs to be fixed before this can be merged: https://github.com/astropy/astropy/actions/runs/12203451342/job/34046435787?pr=17514 |
I find it quite disturbing that you have approved this pull request when it is clear that you have not read the discussion at all. |
|
Like many (certainly like me), @pllim probably looks at the actual changes and approves those, and then realizes a test is broken. That that was discussed further above just goes to show that the github way of organizing things is far from optimal -- reading longer discussions is extremely tedious since there is no organization, no way to resolve pieces of the main thread, etc. Anyway, @pllim, know we know you are the one that keeps this ship going! Thanks!! |
|
Yes, indeed I jumped to the diff first. I do not have time to always read all the discussions, especially since now I am trying to play catch up after being away. But that is neither here nor there. I should probably dismiss my approval for now. Thanks, all. |
|
Re: double trouble -- A workaround is to set a Line 15 in 3ca1a10 Or maybe like this: https://github-actions-workflows.openastronomy.org/en/stable/tox.html#setenv Not pretty but it would disappear when we remove the test runner. |
|
I just merged #17529 and set its backport to auto-merge. |
It should be possible to configure the `astropy` configuration and cache directories with the `XDG_CONFIG_HOME` and `XDG_CACHE_HOME` environment variables, but the new test reveals that the latter has no effect.
657c91a (MNT: Run PTH flake test in prep for supporting pathlib (config)) introduced a bug which caused the `XDG_CACHE_HOME` environment variable to be ignored and `XDG_CONFIG_HOME` to control both configuration and cache directories (if set). The correct behaviour has been restored, but removing any cache files from unintended locations is not attempted.
56ddade to
ce43637
Compare
|
Approving now but giving time for @eerovaher to answer the one hanging thread before I merge |
…514-on-v7.0.x Backport PR #17514 on branch v7.0.x (Fix configuring `astropy` cache location)
Description
657c91a (from #16997) introduced a bug to customizing the
astropycache directory. TheXDG_CACHE_HOMEenvironment variable has no effect, insteadXDG_CONFIG_HOMEcontrols both configuration and cache directories.The first commit adds a regression test to reveal the bug, the second fixes it.
PS https://www.astropy.org/team does not document who the maintainers for
configare.