Skip to content

Ensure Masked test robustness when tests are run in parallel#15327

Merged
mhvk merged 1 commit intoastropy:mainfrom
mhvk:utils-masked-test-robustness-fix
Sep 18, 2023
Merged

Ensure Masked test robustness when tests are run in parallel#15327
mhvk merged 1 commit intoastropy:mainfrom
mhvk:utils-masked-test-robustness-fix

Conversation

@mhvk
Copy link
Contributor

@mhvk mhvk commented Sep 16, 2023

This pull request is to address the irregular test failures reported in #15316, where it was noted that occasionally, test_masked.py::TestMaskedQuantityInitialization::test_masked_quantity_getting failed with KeyError. The test assumed that a MaskedQuantity had been used before, which is not true if this test is run first.

In the PR, the first commit fixes it by explicitly defining the MaskedQuantity in setup_class; the second commit refactors the whole class a bit, to make it a bit more logical. They should be kept separate.

Fixes #15316

  • [ X] 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.

@github-actions
Copy link
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?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • 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.

@mhvk
Copy link
Contributor Author

mhvk commented Sep 16, 2023

Oops, #15326 preceded me! I'll rebase keeping just the single new commit (no need to backport then either).

@mhvk mhvk force-pushed the utils-masked-test-robustness-fix branch from 747a49a to 0693591 Compare September 16, 2023 12:49
@mhvk
Copy link
Contributor Author

mhvk commented Sep 16, 2023

Darn, of course now I need to rebase again when #15326 is merged. Silly me.

@mhvk mhvk force-pushed the utils-masked-test-robustness-fix branch from 0693591 to 0c61647 Compare September 18, 2023 13:24
@mhvk
Copy link
Contributor Author

mhvk commented Sep 18, 2023

Rebased...

@pllim
Copy link
Member

pllim commented Sep 18, 2023

Who should review the content here? @nstarman ?

@mhvk mhvk force-pushed the utils-masked-test-robustness-fix branch from 0c61647 to 7d4c799 Compare September 18, 2023 17:59
Copy link
Member

@nstarman nstarman left a comment

Choose a reason for hiding this comment

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

All these tests look very reasonable and should prevent errors when run in parallel.

# First check setup_class (or previous use) defined a cache entry.
mcls = Masked._masked_classes[type(self.a)]
# Next check this is what one gets now.
MQ = Masked(Quantity)
Copy link
Member

Choose a reason for hiding this comment

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

Why does this line not use self.MQ like the other tests? I must have missed some earlier discussions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, here I want to test that if I try to create MQ again that I don't get a new version (e.g., in principle, the caching could be broken, and every time one calls it, it creates a new class and just caches that one).

@mhvk mhvk merged commit d97e215 into astropy:main Sep 18, 2023
@mhvk mhvk deleted the utils-masked-test-robustness-fix branch September 18, 2023 20:16
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Sep 18, 2023
@mhvk mhvk modified the milestones: v5.3.4, v6.0 Sep 18, 2023
@mhvk
Copy link
Contributor Author

mhvk commented Sep 18, 2023

Oops, I missed that without the original commit to actually fix a bug, this further refactoring and cleaning up really does not need to be backported anymore. I closed the backport PR and changed the labels here. Hopefully that's enough!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_masked.py::TestMaskedQuantityInitialization::test_masked_quantity_getting can fail with KeyError

3 participants