-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
Deprecate cleanup
fixture; replace with gonna_run_dask
fixture
#6854
base: main
Are you sure you want to change the base?
Conversation
I'm really unsure whether or not I like this. The way in which fixtures are used seems very tangled and inconsistent. Maybe we should just put |
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 15 files ±0 15 suites ±0 6h 31m 10s ⏱️ + 3m 20s Results for commit 6386486. ± Comparison against base commit bf53760. ♻️ This comment has been updated with latest results. |
The "what fixtures should be deprecated" conversation probably belongs into #6806 I suggest to get started on that one before introducing any deprecations really. We can define the fixtures we want to be public there and then deprecate basically all of utils_test in one go in favor of a public testing module and a private one. The private one can then be iterated on quickly to find a good match for our needs |
distributed/utils_test.py
Outdated
raise RuntimeError( | ||
"The `distributed.utils_test.cleanup` fixture is deprecated. " | ||
"You should not be using this fixture directly. In most cases, use:\n" | ||
" * `gen_cluster` if you just need to run a cluster\n" | ||
" * `client` fixture or `cluster` contextmanager if you need a cluster in subprocesses\n" | ||
" * `loop` + `popen` to call the dask CLIs yourself, and connect a Client to it using the `loop`\n" | ||
"These methods all will check for resource leaks and set up default config values for you. " | ||
"If none of these methods work, and you want to continue launching dask your own (likely deprecated) " | ||
"way in tests (like calling `Client(..., loop=None)`, then use the `gonna_run_dask` fixture to " | ||
"set config values for tests, and check for resource leaks." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise RuntimeError( | |
"The `distributed.utils_test.cleanup` fixture is deprecated. " | |
"You should not be using this fixture directly. In most cases, use:\n" | |
" * `gen_cluster` if you just need to run a cluster\n" | |
" * `client` fixture or `cluster` contextmanager if you need a cluster in subprocesses\n" | |
" * `loop` + `popen` to call the dask CLIs yourself, and connect a Client to it using the `loop`\n" | |
"These methods all will check for resource leaks and set up default config values for you. " | |
"If none of these methods work, and you want to continue launching dask your own (likely deprecated) " | |
"way in tests (like calling `Client(..., loop=None)`, then use the `gonna_run_dask` fixture to " | |
"set config values for tests, and check for resource leaks." | |
) |
@pytest.fixture | ||
def cleanup(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're going to break everyone who uses this fixture anyway, so we can just use the fact that independent fixtures need importing even if they are added as simple dependencies to get the news out
@pytest.fixture | |
def cleanup(): | |
@pytest.fixture | |
def cleanup(gonna_run_dask): | |
# cleanup is deprecated in favor of gonna_run_dask see https://github.com/dask/distributed/pull/6854/ | |
return gonna_run_dask |
I don't like the name "gonna_run_dask", however once "cleanup" had this new name it was obvious to me which tests didn't need it, so clearly the new name is better, and I'm happy to go with it if nothing else is suggested, which puts me at a begrudging +1 the problems I have with the name are:
some paints for your bikeshed: @pytest.fixture
def distributes():
with _check_clean(), config_for_cluster_tests():
yield |
I kind of like the informality of |
Addresses #6822 (comment), where some tests were using the
cleanup
fixture for its behavior setting default config values (such as disabling the profiler).I didn't like that muddying of concerns.
cleanup
should just assert that things aren't leaked. If you want config values, that should be separate IMO.cleanup
seemed to be currently used like "throw this in whenever you're going to launch a dask cluster, can't hurt". I just don't like the naming of that, so this adds a newgonna_run_dask
fixture for convenience, which combinescleanup
+config_for_cluster_tests
(which is exactly whatcleanup
used to be be before #6822).This deprecates the
cleanup
fixture right now and raises an error pointing you togonna_run_dask
. Maybe that's a bad idea? I just didn't see many/any standalone uses ofcleanup
that actually seemed necessary (either in things that weren't making threads/processes, or already were usingloop
, which runs cleanup itself).This would break things for any downstream projects using
cleanup
directly.cc @graingert
pre-commit run --all-files