From 1d683c4bf08160338150e099088f71c8668d88d2 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 5 Jan 2021 16:14:24 -0500 Subject: [PATCH 01/12] TST Download datasets before running pytest [scipy-dev] --- conftest.py | 75 ++++++++++++++++++- sklearn/datasets/tests/conftest.py | 60 --------------- .../ensemble/tests/test_gradient_boosting.py | 7 +- 3 files changed, 76 insertions(+), 66 deletions(-) diff --git a/conftest.py b/conftest.py index 5c48de4ac36a3..661ecd61b9d0a 100644 --- a/conftest.py +++ b/conftest.py @@ -8,6 +8,8 @@ import os import platform import sys +from os import environ +from functools import wraps import pytest from _pytest.doctest import DoctestItem @@ -16,6 +18,13 @@ from sklearn.externals import _pilutil from sklearn._min_dependencies import PYTEST_MIN_VERSION from sklearn.utils.fixes import np_version, parse_version +from sklearn.datasets import fetch_20newsgroups +from sklearn.datasets import fetch_20newsgroups_vectorized +from sklearn.datasets import fetch_california_housing +from sklearn.datasets import fetch_covtype +from sklearn.datasets import fetch_kddcup99 +from sklearn.datasets import fetch_olivetti_faces +from sklearn.datasets import fetch_rcv1 if parse_version(pytest.__version__) < parse_version(PYTEST_MIN_VERSION): @@ -24,6 +33,43 @@ .format(PYTEST_MIN_VERSION)) +dataset_fetchers = { + 'fetch_20newsgroups_fxt': fetch_20newsgroups, + 'fetch_20newsgroups_vectorized_fxt': fetch_20newsgroups_vectorized, + 'fetch_california_housing_fxt': fetch_california_housing, + 'fetch_covtype_fxt': fetch_covtype, + 'fetch_kddcup99_fxt': fetch_kddcup99, + 'fetch_olivetti_faces_fxt': fetch_olivetti_faces, + 'fetch_rcv1_fxt': fetch_rcv1, +} + + +# fetching a dataset with this fixture will never download if missing +def _fetch_fixture(f): + """ Fetch dataset (download if missing and requested by environment) """ + download_if_missing = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' + + @wraps(f) + def wrapped(*args, **kwargs): + kwargs['download_if_missing'] = download_if_missing + try: + return f(*args, **kwargs) + except IOError: + pytest.skip("test requires -m 'not skipnetwork' to run") + return pytest.fixture(lambda: wrapped) + + +# Adds fixtures for fetching data +fetch_20newsgroups_fxt = _fetch_fixture(fetch_20newsgroups) +fetch_20newsgroups_vectorized_fxt = \ + _fetch_fixture(fetch_20newsgroups_vectorized) +fetch_california_housing_fxt = _fetch_fixture(fetch_california_housing) +fetch_covtype_fxt = _fetch_fixture(fetch_covtype) +fetch_kddcup99_fxt = _fetch_fixture(fetch_kddcup99) +fetch_olivetti_faces_fxt = _fetch_fixture(fetch_olivetti_faces) +fetch_rcv1_fxt = _fetch_fixture(fetch_rcv1) + + def pytest_addoption(parser): parser.addoption("--skip-network", action="store_true", default=False, help="skip network tests") @@ -50,11 +96,36 @@ def pytest_collection_modifyitems(config, items): ) item.add_marker(marker) + run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' + skip_network = pytest.mark.skip( + reason="test requires internet connectivity") + + # download datasets during collection to avoid thread unsafe behavior + # when running pytest in parallel with pytest-xdist + dataset_features_set = set(dataset_fetchers) + datasets_to_download = set() + + for item in items: + item_keywords = set(item.keywords) + dataset_to_fetch = item_keywords & dataset_features_set + if not dataset_to_fetch: + continue + + if run_network_tests: + datasets_to_download |= dataset_to_fetch + else: + # network tests are skipped + item.add_marker(skip_network) + + # download datasets that are needed to avoid thread unsafe behavior + # by pytest-xdist + if run_network_tests: + for name in datasets_to_download: + dataset_fetchers[name]() + # Skip tests which require internet if the flag is provided if (config.getoption("--skip-network") or int(os.environ.get("SKLEARN_SKIP_NETWORK_TESTS", "0"))): - skip_network = pytest.mark.skip( - reason="test requires internet connectivity") for item in items: if "network" in item.keywords: item.add_marker(skip_network) diff --git a/sklearn/datasets/tests/conftest.py b/sklearn/datasets/tests/conftest.py index 4612cd5deb4bc..cf356d6ca3b10 100644 --- a/sklearn/datasets/tests/conftest.py +++ b/sklearn/datasets/tests/conftest.py @@ -1,67 +1,7 @@ """ Network tests are only run, if data is already locally available, or if download is specifically requested by environment variable.""" import builtins -from functools import wraps -from os import environ import pytest -from sklearn.datasets import fetch_20newsgroups -from sklearn.datasets import fetch_20newsgroups_vectorized -from sklearn.datasets import fetch_california_housing -from sklearn.datasets import fetch_covtype -from sklearn.datasets import fetch_kddcup99 -from sklearn.datasets import fetch_olivetti_faces -from sklearn.datasets import fetch_rcv1 - - -def _wrapped_fetch(f, dataset_name): - """ Fetch dataset (download if missing and requested by environment) """ - download_if_missing = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' - - @wraps(f) - def wrapped(*args, **kwargs): - kwargs['download_if_missing'] = download_if_missing - try: - return f(*args, **kwargs) - except IOError: - pytest.skip("Download {} to run this test".format(dataset_name)) - return wrapped - - -@pytest.fixture -def fetch_20newsgroups_fxt(): - return _wrapped_fetch(fetch_20newsgroups, dataset_name='20newsgroups') - - -@pytest.fixture -def fetch_20newsgroups_vectorized_fxt(): - return _wrapped_fetch(fetch_20newsgroups_vectorized, - dataset_name='20newsgroups_vectorized') - - -@pytest.fixture -def fetch_california_housing_fxt(): - return _wrapped_fetch(fetch_california_housing, - dataset_name='california_housing') - - -@pytest.fixture -def fetch_covtype_fxt(): - return _wrapped_fetch(fetch_covtype, dataset_name='covtype') - - -@pytest.fixture -def fetch_kddcup99_fxt(): - return _wrapped_fetch(fetch_kddcup99, dataset_name='kddcup99') - - -@pytest.fixture -def fetch_olivetti_faces_fxt(): - return _wrapped_fetch(fetch_olivetti_faces, dataset_name='olivetti_faces') - - -@pytest.fixture -def fetch_rcv1_fxt(): - return _wrapped_fetch(fetch_rcv1, dataset_name='rcv1') @pytest.fixture diff --git a/sklearn/ensemble/tests/test_gradient_boosting.py b/sklearn/ensemble/tests/test_gradient_boosting.py index 256b79db4865c..498e5bf38a675 100644 --- a/sklearn/ensemble/tests/test_gradient_boosting.py +++ b/sklearn/ensemble/tests/test_gradient_boosting.py @@ -13,7 +13,7 @@ from sklearn import datasets from sklearn.base import clone -from sklearn.datasets import (make_classification, fetch_california_housing, +from sklearn.datasets import (make_classification, make_regression) from sklearn.ensemble import GradientBoostingClassifier from sklearn.ensemble import GradientBoostingRegressor @@ -345,8 +345,7 @@ def test_max_feature_regression(): assert deviance < 0.5, "GB failed with deviance %.4f" % deviance -@pytest.mark.network -def test_feature_importance_regression(): +def test_feature_importance_regression(fetch_california_housing_fxt): """Test that Gini importance is calculated correctly. This test follows the example from [1]_ (pg. 373). @@ -354,7 +353,7 @@ def test_feature_importance_regression(): .. [1] Friedman, J., Hastie, T., & Tibshirani, R. (2001). The elements of statistical learning. New York: Springer series in statistics. """ - california = fetch_california_housing() + california = fetch_california_housing_fxt() X, y = california.data, california.target X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0) From a4787dc9caf3e9fed70d2eb38948d4940929985f Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 6 Jan 2021 14:13:39 -0500 Subject: [PATCH 02/12] CI Only use SKLEARN_SKIP_NETWORK_TESTS [scipy-dev] --- conftest.py | 14 +------------- doc/computing/parallelism.rst | 3 ++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/conftest.py b/conftest.py index 661ecd61b9d0a..cc4a9d1f8c807 100644 --- a/conftest.py +++ b/conftest.py @@ -5,7 +5,6 @@ # doc/modules/clustering.rst and use sklearn from the local folder rather than # the one from site-packages. -import os import platform import sys from os import environ @@ -70,11 +69,6 @@ def wrapped(*args, **kwargs): fetch_rcv1_fxt = _fetch_fixture(fetch_rcv1) -def pytest_addoption(parser): - parser.addoption("--skip-network", action="store_true", default=False, - help="skip network tests") - - def pytest_collection_modifyitems(config, items): for item in items: # FeatureHasher is not compatible with PyPy @@ -121,15 +115,9 @@ def pytest_collection_modifyitems(config, items): # by pytest-xdist if run_network_tests: for name in datasets_to_download: + print("Sequential pre-caching of dataset {name}...") dataset_fetchers[name]() - # Skip tests which require internet if the flag is provided - if (config.getoption("--skip-network") - or int(os.environ.get("SKLEARN_SKIP_NETWORK_TESTS", "0"))): - for item in items: - if "network" in item.keywords: - item.add_marker(skip_network) - # numpy changed the str/repr formatting of numpy arrays in 1.14. We want to # run doctests only for numpy >= 1.14. skip_doctests = False diff --git a/doc/computing/parallelism.rst b/doc/computing/parallelism.rst index c30d0790c1f01..0cc605b735617 100644 --- a/doc/computing/parallelism.rst +++ b/doc/computing/parallelism.rst @@ -209,4 +209,5 @@ These environment variables should be set before importing scikit-learn. :SKLEARN_SKIP_NETWORK_TESTS: When this environment variable is set to a non zero value, the tests - that need network access are skipped. + that need network access are skipped. When this environment variable is + not set then network tests are skipped. From ee3b46b7e57b2e1c7a4769d93d787b14a019da88 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 8 Jan 2021 10:50:45 -0500 Subject: [PATCH 03/12] TST Move fixtures up a level [scipy-dev] --- conftest.py | 75 ------------------------------------------- sklearn/conftest.py | 77 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 75 deletions(-) diff --git a/conftest.py b/conftest.py index cc4a9d1f8c807..aec49c03ae13d 100644 --- a/conftest.py +++ b/conftest.py @@ -7,8 +7,6 @@ import platform import sys -from os import environ -from functools import wraps import pytest from _pytest.doctest import DoctestItem @@ -17,14 +15,6 @@ from sklearn.externals import _pilutil from sklearn._min_dependencies import PYTEST_MIN_VERSION from sklearn.utils.fixes import np_version, parse_version -from sklearn.datasets import fetch_20newsgroups -from sklearn.datasets import fetch_20newsgroups_vectorized -from sklearn.datasets import fetch_california_housing -from sklearn.datasets import fetch_covtype -from sklearn.datasets import fetch_kddcup99 -from sklearn.datasets import fetch_olivetti_faces -from sklearn.datasets import fetch_rcv1 - if parse_version(pytest.__version__) < parse_version(PYTEST_MIN_VERSION): raise ImportError('Your version of pytest is too old, you should have ' @@ -32,43 +22,6 @@ .format(PYTEST_MIN_VERSION)) -dataset_fetchers = { - 'fetch_20newsgroups_fxt': fetch_20newsgroups, - 'fetch_20newsgroups_vectorized_fxt': fetch_20newsgroups_vectorized, - 'fetch_california_housing_fxt': fetch_california_housing, - 'fetch_covtype_fxt': fetch_covtype, - 'fetch_kddcup99_fxt': fetch_kddcup99, - 'fetch_olivetti_faces_fxt': fetch_olivetti_faces, - 'fetch_rcv1_fxt': fetch_rcv1, -} - - -# fetching a dataset with this fixture will never download if missing -def _fetch_fixture(f): - """ Fetch dataset (download if missing and requested by environment) """ - download_if_missing = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' - - @wraps(f) - def wrapped(*args, **kwargs): - kwargs['download_if_missing'] = download_if_missing - try: - return f(*args, **kwargs) - except IOError: - pytest.skip("test requires -m 'not skipnetwork' to run") - return pytest.fixture(lambda: wrapped) - - -# Adds fixtures for fetching data -fetch_20newsgroups_fxt = _fetch_fixture(fetch_20newsgroups) -fetch_20newsgroups_vectorized_fxt = \ - _fetch_fixture(fetch_20newsgroups_vectorized) -fetch_california_housing_fxt = _fetch_fixture(fetch_california_housing) -fetch_covtype_fxt = _fetch_fixture(fetch_covtype) -fetch_kddcup99_fxt = _fetch_fixture(fetch_kddcup99) -fetch_olivetti_faces_fxt = _fetch_fixture(fetch_olivetti_faces) -fetch_rcv1_fxt = _fetch_fixture(fetch_rcv1) - - def pytest_collection_modifyitems(config, items): for item in items: # FeatureHasher is not compatible with PyPy @@ -90,34 +43,6 @@ def pytest_collection_modifyitems(config, items): ) item.add_marker(marker) - run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' - skip_network = pytest.mark.skip( - reason="test requires internet connectivity") - - # download datasets during collection to avoid thread unsafe behavior - # when running pytest in parallel with pytest-xdist - dataset_features_set = set(dataset_fetchers) - datasets_to_download = set() - - for item in items: - item_keywords = set(item.keywords) - dataset_to_fetch = item_keywords & dataset_features_set - if not dataset_to_fetch: - continue - - if run_network_tests: - datasets_to_download |= dataset_to_fetch - else: - # network tests are skipped - item.add_marker(skip_network) - - # download datasets that are needed to avoid thread unsafe behavior - # by pytest-xdist - if run_network_tests: - for name in datasets_to_download: - print("Sequential pre-caching of dataset {name}...") - dataset_fetchers[name]() - # numpy changed the str/repr formatting of numpy arrays in 1.14. We want to # run doctests only for numpy >= 1.14. skip_doctests = False diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 8a98921342efa..dd24bc40fc8f1 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -1,9 +1,86 @@ import os +from os import environ +from functools import wraps import pytest from threadpoolctl import threadpool_limits from sklearn.utils._openmp_helpers import _openmp_effective_n_threads +from sklearn.datasets import fetch_20newsgroups +from sklearn.datasets import fetch_20newsgroups_vectorized +from sklearn.datasets import fetch_california_housing +from sklearn.datasets import fetch_covtype +from sklearn.datasets import fetch_kddcup99 +from sklearn.datasets import fetch_olivetti_faces +from sklearn.datasets import fetch_rcv1 + + +dataset_fetchers = { + 'fetch_20newsgroups_fxt': fetch_20newsgroups, + 'fetch_20newsgroups_vectorized_fxt': fetch_20newsgroups_vectorized, + 'fetch_california_housing_fxt': fetch_california_housing, + 'fetch_covtype_fxt': fetch_covtype, + 'fetch_kddcup99_fxt': fetch_kddcup99, + 'fetch_olivetti_faces_fxt': fetch_olivetti_faces, + 'fetch_rcv1_fxt': fetch_rcv1, +} + + +# fetching a dataset with this fixture will never download if missing +def _fetch_fixture(f): + """Fetch dataset (download if missing and requested by environment).""" + download_if_missing = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' + + @wraps(f) + def wrapped(*args, **kwargs): + kwargs['download_if_missing'] = download_if_missing + try: + return f(*args, **kwargs) + except IOError: + pytest.skip("test requires -m 'not skipnetwork' to run") + return pytest.fixture(lambda: wrapped) + + +# Adds fixtures for fetching data +fetch_20newsgroups_fxt = _fetch_fixture(fetch_20newsgroups) +fetch_20newsgroups_vectorized_fxt = \ + _fetch_fixture(fetch_20newsgroups_vectorized) +fetch_california_housing_fxt = _fetch_fixture(fetch_california_housing) +fetch_covtype_fxt = _fetch_fixture(fetch_covtype) +fetch_kddcup99_fxt = _fetch_fixture(fetch_kddcup99) +fetch_olivetti_faces_fxt = _fetch_fixture(fetch_olivetti_faces) +fetch_rcv1_fxt = _fetch_fixture(fetch_rcv1) + + +def pytest_collection_modifyitems(config, items): + run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' + skip_network = pytest.mark.skip( + reason="test requires internet connectivity") + + # download datasets during collection to avoid thread unsafe behavior + # when running pytest in parallel with pytest-xdist + dataset_features_set = set(dataset_fetchers) + datasets_to_download = set() + + for item in items: + item_keywords = set(item.keywords) + dataset_to_fetch = item_keywords & dataset_features_set + if not dataset_to_fetch: + continue + + if run_network_tests: + datasets_to_download |= dataset_to_fetch + else: + # network tests are skipped + item.add_marker(skip_network) + + # download datasets that are needed to avoid thread unsafe behavior + # by pytest-xdist + if run_network_tests: + for name in datasets_to_download: + print("Sequential pre-caching of dataset {name}...") + dataset_fetchers[name]() + @pytest.fixture(scope='function') From 0fe2e14086c3c52d88798ce387c5fd7ec55dce87 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 8 Jan 2021 11:15:36 -0500 Subject: [PATCH 04/12] DOC Adds docstring [scipy-dev] --- sklearn/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index dd24bc40fc8f1..08eeee54d863e 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -53,6 +53,13 @@ def wrapped(*args, **kwargs): def pytest_collection_modifyitems(config, items): + """Called after collect is completed. + + Parameters + ---------- + config : pytest config + items : list of collected items + """ run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' skip_network = pytest.mark.skip( reason="test requires internet connectivity") @@ -82,7 +89,6 @@ def pytest_collection_modifyitems(config, items): dataset_fetchers[name]() - @pytest.fixture(scope='function') def pyplot(): """Setup and teardown fixture for matplotlib. From 984730bc002efd132804748d62adaff0b090e662 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Fri, 8 Jan 2021 12:53:03 -0500 Subject: [PATCH 05/12] CI Properly downloads datasets [scipy-dev] --- sklearn/conftest.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 08eeee54d863e..b7f78fcd0082b 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -70,8 +70,8 @@ def pytest_collection_modifyitems(config, items): datasets_to_download = set() for item in items: - item_keywords = set(item.keywords) - dataset_to_fetch = item_keywords & dataset_features_set + item_fixtures = set(item.fixturenames) + dataset_to_fetch = item_fixtures & dataset_features_set if not dataset_to_fetch: continue @@ -85,7 +85,7 @@ def pytest_collection_modifyitems(config, items): # by pytest-xdist if run_network_tests: for name in datasets_to_download: - print("Sequential pre-caching of dataset {name}...") + print(f"Sequential pre-caching of dataset {name}...") dataset_fetchers[name]() From 975ea7844c6674ee9411e5abe3253eadb9ce14b7 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 12 Jan 2021 15:18:08 -0500 Subject: [PATCH 06/12] FIX Checks for fixturenames before checking for fixtures --- sklearn/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index b7f78fcd0082b..942bd8ce12436 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -70,6 +70,8 @@ def pytest_collection_modifyitems(config, items): datasets_to_download = set() for item in items: + if not hasattr(item, "fixturenames"): + continue item_fixtures = set(item.fixturenames) dataset_to_fetch = item_fixtures & dataset_features_set if not dataset_to_fetch: From b2682807efaef23a941a90f02ebd2e7c69951358 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Wed, 13 Jan 2021 09:40:47 +0100 Subject: [PATCH 07/12] [scipy-dev] From 26a65e891be26e7f556c151db9400269ba015135 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Jan 2021 10:06:57 -0500 Subject: [PATCH 08/12] CI Only download on the first worker [scipy-dev] --- sklearn/conftest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 942bd8ce12436..3d9e315be3a6d 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -83,9 +83,11 @@ def pytest_collection_modifyitems(config, items): # network tests are skipped item.add_marker(skip_network) - # download datasets that are needed to avoid thread unsafe behavior - # by pytest-xdist - if run_network_tests: + # Only download datasets on the first worker spawned by pytest-xdist + # to avoid thread unsafe behavior. If pytest-xdist is not used, we still + # download before tests run. + worker_id = environ.get("PYTEST_XDIST_WORKER", "gw0") + if worker_id == "gw0" and run_network_tests: for name in datasets_to_download: print(f"Sequential pre-caching of dataset {name}...") dataset_fetchers[name]() From c1117c5942f23c05a8259b2fe10991e4c76c8303 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Jan 2021 10:21:15 -0500 Subject: [PATCH 09/12] DOC Update message [scipy-dev] --- sklearn/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 3d9e315be3a6d..58038095c6e73 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -37,7 +37,8 @@ def wrapped(*args, **kwargs): try: return f(*args, **kwargs) except IOError: - pytest.skip("test requires -m 'not skipnetwork' to run") + pytest.skip("test is enabled if SKLEARN_SKIP_NETWORK_TESTS is " + "set to 0") return pytest.fixture(lambda: wrapped) @@ -62,7 +63,7 @@ def pytest_collection_modifyitems(config, items): """ run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' skip_network = pytest.mark.skip( - reason="test requires internet connectivity") + reason="test is enabled if SKLEARN_SKIP_NETWORK_TESTS is set to 0") # download datasets during collection to avoid thread unsafe behavior # when running pytest in parallel with pytest-xdist From 9e5659bd55d3d8970a5dd1c97784cdc98cae53da Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Jan 2021 10:51:59 -0500 Subject: [PATCH 10/12] DOC Remove print statement --- sklearn/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 58038095c6e73..bae14e4d54d3d 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -90,7 +90,6 @@ def pytest_collection_modifyitems(config, items): worker_id = environ.get("PYTEST_XDIST_WORKER", "gw0") if worker_id == "gw0" and run_network_tests: for name in datasets_to_download: - print(f"Sequential pre-caching of dataset {name}...") dataset_fetchers[name]() From edf2ee437a020d64d36866687b4a099668c0329a Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Jan 2021 10:55:30 -0500 Subject: [PATCH 11/12] DOC Removes comment --- sklearn/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index bae14e4d54d3d..b7054210238b9 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -26,7 +26,6 @@ } -# fetching a dataset with this fixture will never download if missing def _fetch_fixture(f): """Fetch dataset (download if missing and requested by environment).""" download_if_missing = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' From 9ec96ee6e0c1cae3d1d71a1c8f21d000d751f0a2 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Wed, 13 Jan 2021 10:59:54 -0500 Subject: [PATCH 12/12] ENH Simplify reason [ci skip] --- sklearn/conftest.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index b7054210238b9..2978115e3091c 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -36,8 +36,7 @@ def wrapped(*args, **kwargs): try: return f(*args, **kwargs) except IOError: - pytest.skip("test is enabled if SKLEARN_SKIP_NETWORK_TESTS is " - "set to 0") + pytest.skip("test is enabled when SKLEARN_SKIP_NETWORK_TESTS=0") return pytest.fixture(lambda: wrapped) @@ -62,7 +61,7 @@ def pytest_collection_modifyitems(config, items): """ run_network_tests = environ.get('SKLEARN_SKIP_NETWORK_TESTS', '1') == '0' skip_network = pytest.mark.skip( - reason="test is enabled if SKLEARN_SKIP_NETWORK_TESTS is set to 0") + reason="test is enabled when SKLEARN_SKIP_NETWORK_TESTS=0") # download datasets during collection to avoid thread unsafe behavior # when running pytest in parallel with pytest-xdist