From ac45e5d03cabf67b7673e568c6bd389d8af21e36 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Wed, 2 Jul 2014 13:25:34 +0200 Subject: [PATCH 1/2] MAINT skip tests that require large datadownload under travis --- continuous_integration/test_script.sh | 5 +++++ .../text_analytics/working_with_text_data_fixture.py | 5 +++++ sklearn/utils/testing.py | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 doc/tutorial/text_analytics/working_with_text_data_fixture.py diff --git a/continuous_integration/test_script.sh b/continuous_integration/test_script.sh index 23ea610ab5258..04ec2b5318499 100644 --- a/continuous_integration/test_script.sh +++ b/continuous_integration/test_script.sh @@ -11,6 +11,11 @@ python -c "import numpy; print('numpy %s' % numpy.__version__)" python -c "import scipy; print('scipy %s' % scipy.__version__)" python setup.py build_ext --inplace +# Skip tests that require large downloads over the network to save bandwith +# usage as travis workers are stateless and therefore traditional local +# disk caching does not work. +export SKLEARN_SKIP_NETWORK_TESTS=1 + if [[ "$COVERAGE" == "true" ]]; then make test-coverage else diff --git a/doc/tutorial/text_analytics/working_with_text_data_fixture.py b/doc/tutorial/text_analytics/working_with_text_data_fixture.py new file mode 100644 index 0000000000000..d5be0bcdd309d --- /dev/null +++ b/doc/tutorial/text_analytics/working_with_text_data_fixture.py @@ -0,0 +1,5 @@ +from sklearn.utils.testing import check_skip_network + + +def setup_module(): + check_skip_network() diff --git a/sklearn/utils/testing.py b/sklearn/utils/testing.py index 9568008c388d1..367759cc2f338 100644 --- a/sklearn/utils/testing.py +++ b/sklearn/utils/testing.py @@ -8,6 +8,7 @@ # Arnaud Joly # Denis Engemann # License: BSD 3 clause +import os import inspect import pkgutil import warnings @@ -578,3 +579,11 @@ def clean_warning_registry(): for mod in sys.modules.copy().values(): if hasattr(mod, reg): getattr(mod, reg).clear() + + +def check_skip_network(): + if int(os.environ.get('SKLEARN_SKIP_NETWORK_TESTS', 0)): + raise SkipTest("Text tutorial requires large dataset download") + + +with_network = with_setup(check_skip_network) From 9a4c9f2064c812019148b02fd6baf9ab19961bce Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Fri, 4 Jul 2014 11:48:15 +0200 Subject: [PATCH 2/2] MAINT add docstring to explain the motivation of the fixture --- .../text_analytics/working_with_text_data_fixture.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/tutorial/text_analytics/working_with_text_data_fixture.py b/doc/tutorial/text_analytics/working_with_text_data_fixture.py index d5be0bcdd309d..295e55c3be9ca 100644 --- a/doc/tutorial/text_analytics/working_with_text_data_fixture.py +++ b/doc/tutorial/text_analytics/working_with_text_data_fixture.py @@ -1,3 +1,13 @@ +"""Fixture module to skip the datasets loading when offline + +The 20 newsgroups data is rather large and some CI workers such as travis are +stateless hence will not cache the dataset as regular sklearn users would do. + +The following will skip the execution of the working_with_text_data.rst doctests +is the proper environment variable is configured (see the source code of +check_skip_network for more details). + +""" from sklearn.utils.testing import check_skip_network