Skip to content

ENH/BUG: avoid test pollution from data tests by making APIs resilient against missing cache directories - #19650

Merged
astrofrog merged 1 commit into
astropy:mainfrom
neutrinoceros:config/tst/fixup-isolation
May 15, 2026
Merged

astrofrog merged 1 commit into
astropy:mainfrom
neutrinoceros:config/tst/fixup-isolation

Conversation

@neutrinoceros

@neutrinoceros neutrinoceros commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow up to #19631
close #19636

At the time of opening, I still have exactly one failing test locally, which is both responsible for the remaining bit of pollution I'm seeing (in the form of a test cache dir being created into the default, global location), and a victim of some other kind of pollution: it passes on its own but not when the entire test module is run. I have tools to track the latter down, but I'm opening this as a draft to allow myself to take a step back after a couple hours spent juggling with failures.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@neutrinoceros neutrinoceros added this to the v8.0.0 milestone May 4, 2026
@neutrinoceros neutrinoceros added testing Bug Affects-dev PRs and issues that do not impact an existing Astropy release no-changelog-entry-needed labels May 4, 2026
@github-actions github-actions Bot added config utils utils.iers and removed Affects-dev PRs and issues that do not impact an existing Astropy release no-changelog-entry-needed labels May 4, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@astrofrog astrofrog removed the Bug label May 5, 2026
@neutrinoceros
neutrinoceros force-pushed the config/tst/fixup-isolation branch from 09f237d to 5c9730d Compare May 5, 2026 12:47
@pllim

pllim commented May 5, 2026

Copy link
Copy Markdown
Member

I don't think this is critical for v8.0.0 release, so moving milestone

@pllim pllim modified the milestones: v8.0.0, v8.1.0 May 5, 2026
@neutrinoceros

neutrinoceros commented May 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Please don't. There's a subtle bug I'm still tracking down and plan to fix here, which I really don't want to hit users. It's not that critical for a beta but I plan to get it fixed before rc.

@neutrinoceros neutrinoceros modified the milestones: v8.1.0, v8.0.0 May 5, 2026
@neutrinoceros
neutrinoceros force-pushed the config/tst/fixup-isolation branch from 5c9730d to 221bd27 Compare May 6, 2026 15:14
@neutrinoceros neutrinoceros changed the title ENH: avoid creating cache dirs further ENH: avoid creating cache dirs further (wait for #19685) May 6, 2026
@neutrinoceros
neutrinoceros force-pushed the config/tst/fixup-isolation branch 4 times, most recently from 0e7dc09 to 957fe63 Compare May 7, 2026 06:39
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Thank you. I addressed points 1 to 4.
Points 5 to 7 also seem worth pursuing but require more time than I have right now.

@neutrinoceros
neutrinoceros force-pushed the config/tst/fixup-isolation branch from e9ecd69 to a2c395b Compare May 14, 2026 13:15
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Point 5 is actually nonesense

Changed if not (path).is_dir() → if (path).is_file(). This now lets a non-existent path through

This is simply false because is_file() implies exists()

@neutrinoceros

Copy link
Copy Markdown
Contributor Author
  1. Still holds as a valid critic. I would actually agree that some functions do not need to warn by default, but what I have now allowed me to discover more cases that previously relied on the assumption that querying a cache dir guaranteed its existence. Maybe we can change it here or in a follow up PR (possibly defered to RC ?)
    I think a second human opinion is needed to make a decision though.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author
  1. Is also valid criticism. I think by the time I reached this test case, I was growing tired of doing everything as strictly as possible, so it's true that the quality of this one test was actually reduced as a result. If nothing more pressing comes up, I can address this one tomorrow morning. In the meantime it's also fine if someone else wants to step in.

@neutrinoceros
neutrinoceros marked this pull request as ready for review May 14, 2026 13:54
@pllim

pllim commented May 14, 2026

Copy link
Copy Markdown
Member

I am still uncomfortable with on_missing. Why are things missing in the tests to begin with? We really need to understand rather than just bandaid over it.

Also is this still relevant or can this be simplified after #19740 ?

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Why are things missing in the tests to begin with?

This is absolutely expected as a result of my intended changes: previously these functions silently relied on get_cache_dir creating the directory if it wasn't already there, so they were all written within the assumption that it couldn't be missing by the time they got a path back. I'm intentionally changing them so they don't force the directory to exist, so on_missing isn't a band aid, it's an explicit way to express who's responsible for checking and/or ensuring the dir exists if we actually need it at all.

@neutrinoceros

neutrinoceros commented May 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Also is this still relevant or can this be simplified after #19740 ?

It's still relevant. I think these are actually 2 different problems.

@pllim
pllim force-pushed the config/tst/fixup-isolation branch from a2c395b to bd8a439 Compare May 14, 2026 18:39
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

Point 5 is actually nonesense

It's possible that I misread the description. This should be double checked

@astrofrog

Copy link
Copy Markdown
Member

Let's check/do 5, 6, 7 in a follow-up

@astrofrog
astrofrog merged commit d818988 into astropy:main May 15, 2026
43 of 45 checks passed
@lumberbot-app

This comment was marked as resolved.

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

this patch was only meant for 8.0+, it cannot (nor needs to) be backported to 7.2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v8.0.x on-merge: backport to v8.0.x Bug config Extra CI Run cron CI as part of PR testing utils.iers utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: Rearrange OSError logic so it makes sense

3 participants