Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Generalize handling of resource-intensive tests #12350

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

Closed
wants to merge 1 commit into from

Conversation

astrofrog
Copy link
Member

@astrofrog astrofrog commented Nov 1, 2021

Description

This renames the environment variable for the big table tests to be more general and usable by other tests, and adds a tox option to more easily run these tests without setting an environment variable.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • 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 "When to rebase and squash commits".
  • 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.
  • 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 a milestone set? Milestone must be set but astropy-bot check might be missing; 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.

…on, and document how to write tests that need a lot of resources
@dhomeier
Copy link
Contributor

dhomeier commented Nov 2, 2021

Would any of the weekly crons be using the intensive option?

Copy link
Contributor

@dhomeier dhomeier left a comment

Choose a reason for hiding this comment

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

Thanks, this looks very useful. Apart from the stylistic and usage notes, good to go in once the readthedocs failure is fixed.

Comment on lines +460 to +461
Tests that have large disk and/or memory requirements
====================================
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Tests that have large disk and/or memory requirements
====================================
Tests that have large disk and/or memory requirements
=====================================================

Sphinx warning/readthedocs failure

Comment on lines +983 to 985
@pytest.mark.skipif(not os.getenv('TEST_INTENSIVE'),
reason='Environment variable TEST_INTENSIVE must be '
'defined to run this test')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.skipif(not os.getenv('TEST_INTENSIVE'),
reason='Environment variable TEST_INTENSIVE must be '
'defined to run this test')
@pytest.mark.skipif(os.getenv('TEST_INTENSIVE', 0) == 0,
reason='Environment variable TEST_INTENSIVE must be defined to run this test')

Just found that I intuitively expected the env var set to 0 to disable the tests; this would also be more consistent with how we are using the ASTROPY_USE_ vars (also noticed that setup is using os.environ.get(), whatever the correct Zen is here ;-).
I prefer it without further linebreak, but unfortunately this would make the docs example break the line...

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have any consistent zen in this department:

env:
ARCH_ON_CI: "normal"
IS_CRON: "false"

I would have named it SHOW_ME_THE_MONEY but this works too.

Copy link
Contributor

Choose a reason for hiding this comment

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

But those are checking the value as well.
TEST_INTENSIVE="False" or TEST_INTENSIVE=0 did let the tests run.

Copy link
Member

Choose a reason for hiding this comment

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

Re: values -- Yes, I agree with @dhomeier . The check should be more strict to only let it run when the value is 1, as documented.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be willing to allow anything that could be interpreted as True, but in fact my suggestion will still accept 'false' as well...

@@ -1014,8 +1014,8 @@ def test_read_big_table(tmpdir):
assert len(t) == NB_ROWS


@pytest.mark.skipif(not os.getenv('TEST_READ_HUGE_FILE'),
reason='Environment variable TEST_READ_HUGE_FILE must be '
@pytest.mark.skipif(not os.getenv('TEST_INTENSIVE'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.skipif(not os.getenv('TEST_INTENSIVE'),
@pytest.mark.skipif(os.getenv('TEST_INTENSIVE', 0) == 0,

@dhomeier
Copy link
Contributor

dhomeier commented Nov 2, 2021

Not sure about the changelog – do we generally include them for functionality only visible to developers?

@astrofrog
Copy link
Member Author

Would any of the weekly crons be using the intensive option?

No, the GitHub actions workers don't have enough RAM

Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Deferring final review to @dhomeier , but this looks good to me!

@dhomeier dhomeier added the 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label Nov 4, 2021
@dhomeier
Copy link
Contributor

dhomeier commented Nov 4, 2021

Marked this as OK when readthedocs is fixed, but I think with @pllim there are at least 2 votes for checking
os.getenv('TEST_INTENSIVE', 0) != 0 ?

@taldcroft
Copy link
Member

Marked this as OK when readthedocs is fixed, but I think with @pllim there are at least 2 votes for checking
os.getenv('TEST_INTENSIVE', 0) != 0 ?

No opinion here one way or the other.

@saimn saimn mentioned this pull request Nov 23, 2021
9 tasks
@saimn
Copy link
Contributor

saimn commented Nov 23, 2021

I think just checking if an environment variable is set or unset is enough, the value doesn't matter and having a complex condition in every test isn't ideal.
But I wanted to propose something else: why not using pytest markers instead ? I think there is a need for more specific markers (e.g. memory intensive, cpu intensive, the thread safety ones would be good candidates: #12522 (comment)), and pytest markers seems more flexible for that. We could exclude those markers by default with addopts, and run the cpu intensive one in a dedicated cron job for example.

@Cadair
Copy link
Member

Cadair commented Nov 24, 2021

+1 for markers, that's definitely the pytest tool for this job.

@astrofrog
Copy link
Member Author

astrofrog commented Nov 24, 2021

I don't have much time to work on this so happy for someone to take the lead on pytest markers (and we can then close this PR)

@pllim pllim added Upstream Fix Required and removed 💤 merge-when-ci-passes Do not use: We have auto-merge option now. labels Dec 6, 2021
@nstarman
Copy link
Member

nstarman commented Jan 12, 2022

This looks very useful. I've been looking for something like this for the new cosmology test suite.
What's the upstream-fix-required for?

@pllim
Copy link
Member

pllim commented Jan 12, 2022

What's the upstream-fix-required for?

Ideally, the pytest marker would be upstream from pytest-astropy or something.

@pllim
Copy link
Member

pllim commented Feb 10, 2022

Closing in favor of #12764 . Thanks anyway!

@pllim pllim closed this Feb 10, 2022
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.

7 participants