From eba1e46abdbc9bb2da70c2cc7cf4638e76d7a19b Mon Sep 17 00:00:00 2001 From: adrinjalali Date: Mon, 28 Mar 2022 17:26:21 +0200 Subject: [PATCH 1/8] move pluging to root folder --- conftest.py | 3 +++ sklearn/conftest.py | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index e4e478d2d72d7..74006980443bc 100644 --- a/conftest.py +++ b/conftest.py @@ -4,3 +4,6 @@ # details. For example, this allows to build extensions in place and run pytest # doc/modules/clustering.rst and use sklearn from the local folder rather than # the one from site-packages. + +# This plugin is necessary to define the random seed fixture +pytest_plugins = ("sklearn.tests.random_seed",) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index b6bde190ad3fb..766803cf2c56e 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -21,10 +21,6 @@ from sklearn.datasets import fetch_rcv1 -# This plugin is necessary to define the random seed fixture -pytest_plugins = ("sklearn.tests.random_seed",) - - if parse_version(pytest.__version__) < parse_version(PYTEST_MIN_VERSION): raise ImportError( "Your version of pytest is too old, you should have " From 5f6daf457b68b950924bf62e83666e34dc27c592 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 28 Mar 2022 13:28:45 -0400 Subject: [PATCH 2/8] MNT Removes pytest_plugins --- build_tools/circle/build_test_arm.sh | 1 + conftest.py | 3 -- setup.cfg | 71 ---------------------------- 3 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 setup.cfg diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index c27353e548940..8097430f3f8d7 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -81,6 +81,7 @@ ccache -s --verbose mamba list +cp setup.cfg /tmp # Changing directory not to have module resolution use scikit-learn source # directory but to the installed package. cd /tmp diff --git a/conftest.py b/conftest.py index 74006980443bc..e4e478d2d72d7 100644 --- a/conftest.py +++ b/conftest.py @@ -4,6 +4,3 @@ # details. For example, this allows to build extensions in place and run pytest # doc/modules/clustering.rst and use sklearn from the local folder rather than # the one from site-packages. - -# This plugin is necessary to define the random seed fixture -pytest_plugins = ("sklearn.tests.random_seed",) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2d59f866547c8..0000000000000 --- a/setup.cfg +++ /dev/null @@ -1,71 +0,0 @@ -[aliases] -test = pytest - -[tool:pytest] -# disable-pytest-warnings should be removed once we rewrite tests -# using yield with parametrize -doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS -testpaths = sklearn -addopts = - --doctest-modules - --disable-pytest-warnings - --color=yes - # Activate the plugin explicitly to ensure that the seed is reported - # correctly on the CI when running `pytest --pyargs sklearn` from the - # source folder. - -p sklearn.tests.random_seed - -rN - -filterwarnings = - ignore:the matrix subclass:PendingDeprecationWarning - -[flake8] -# max line length for black -max-line-length = 88 -target-version = ['py37'] -# Default flake8 3.5 ignored flags -ignore= - E24, # check ignored by default in flake8. Meaning unclear. - E121, # continuation line under-indented - E123, # closing bracket does not match indentation - E126, # continuation line over-indented for hanging indent - E203, # space before : (needed for how black formats slicing) - E226, # missing whitespace around arithmetic operator - E704, # multiple statements on one line (def) - E731, # do not assign a lambda expression, use a def - E741, # do not use variables named ‘l’, ‘O’, or ‘I’ - W503, # line break before binary operator - W504 # line break after binary operator -exclude= - .git, - __pycache__, - dist, - sklearn/externals, - doc/_build, - doc/auto_examples, - doc/tutorial, - build - -# It's fine not to put the import at the top of the file in the examples -# folder. -per-file-ignores = - examples/*: E402 - doc/conf.py: E402 - -[mypy] -ignore_missing_imports = True -allow_redefinition = True - -[check-manifest] -# ignore files missing in VCS -ignore = - sklearn/_loss/_loss.pyx - sklearn/linear_model/_sag_fast.pyx - sklearn/utils/_seq_dataset.pyx - sklearn/utils/_seq_dataset.pxd - sklearn/utils/_weight_vector.pyx - sklearn/utils/_weight_vector.pxd - -[codespell] -skip = ./.git,./.mypy_cache,./doc/themes/scikit-learn-modern/static/js,./sklearn/feature_extraction/_stop_words.py,./doc/_build,./doc/auto_examples,./doc/modules/generated -ignore-words = build_tools/codespell_ignore_words.txt From 07f665f70dc2e411dc8a666f4a8844fd8ac8349e Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 28 Mar 2022 13:29:14 -0400 Subject: [PATCH 3/8] BLD [cd build] From a80dd902f651a963d33669c80b2bb6a3326607cd Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 28 Mar 2022 13:31:11 -0400 Subject: [PATCH 4/8] REV Bring back setup.cfg [cd build] --- setup.cfg | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000000000..2d59f866547c8 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,71 @@ +[aliases] +test = pytest + +[tool:pytest] +# disable-pytest-warnings should be removed once we rewrite tests +# using yield with parametrize +doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS +testpaths = sklearn +addopts = + --doctest-modules + --disable-pytest-warnings + --color=yes + # Activate the plugin explicitly to ensure that the seed is reported + # correctly on the CI when running `pytest --pyargs sklearn` from the + # source folder. + -p sklearn.tests.random_seed + -rN + +filterwarnings = + ignore:the matrix subclass:PendingDeprecationWarning + +[flake8] +# max line length for black +max-line-length = 88 +target-version = ['py37'] +# Default flake8 3.5 ignored flags +ignore= + E24, # check ignored by default in flake8. Meaning unclear. + E121, # continuation line under-indented + E123, # closing bracket does not match indentation + E126, # continuation line over-indented for hanging indent + E203, # space before : (needed for how black formats slicing) + E226, # missing whitespace around arithmetic operator + E704, # multiple statements on one line (def) + E731, # do not assign a lambda expression, use a def + E741, # do not use variables named ‘l’, ‘O’, or ‘I’ + W503, # line break before binary operator + W504 # line break after binary operator +exclude= + .git, + __pycache__, + dist, + sklearn/externals, + doc/_build, + doc/auto_examples, + doc/tutorial, + build + +# It's fine not to put the import at the top of the file in the examples +# folder. +per-file-ignores = + examples/*: E402 + doc/conf.py: E402 + +[mypy] +ignore_missing_imports = True +allow_redefinition = True + +[check-manifest] +# ignore files missing in VCS +ignore = + sklearn/_loss/_loss.pyx + sklearn/linear_model/_sag_fast.pyx + sklearn/utils/_seq_dataset.pyx + sklearn/utils/_seq_dataset.pxd + sklearn/utils/_weight_vector.pyx + sklearn/utils/_weight_vector.pxd + +[codespell] +skip = ./.git,./.mypy_cache,./doc/themes/scikit-learn-modern/static/js,./sklearn/feature_extraction/_stop_words.py,./doc/_build,./doc/auto_examples,./doc/modules/generated +ignore-words = build_tools/codespell_ignore_words.txt From 4f4c04a6c9f750e850f41e4fb33de975554d6608 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 28 Mar 2022 14:11:45 -0400 Subject: [PATCH 5/8] REV Try original solution --- conftest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conftest.py b/conftest.py index e4e478d2d72d7..74006980443bc 100644 --- a/conftest.py +++ b/conftest.py @@ -4,3 +4,6 @@ # details. For example, this allows to build extensions in place and run pytest # doc/modules/clustering.rst and use sklearn from the local folder rather than # the one from site-packages. + +# This plugin is necessary to define the random seed fixture +pytest_plugins = ("sklearn.tests.random_seed",) From 942b0822f97836c5b79d2d032e100604333a3c87 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Mon, 28 Mar 2022 14:11:58 -0400 Subject: [PATCH 6/8] CI [cd build] From 65ec64d78c82b6029143c646f941abdc94c2ebca Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 29 Mar 2022 20:07:15 -0400 Subject: [PATCH 7/8] FIX Try registering another way --- build_tools/circle/build_test_arm.sh | 1 - conftest.py | 3 --- sklearn/conftest.py | 5 +++++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build_tools/circle/build_test_arm.sh b/build_tools/circle/build_test_arm.sh index 8097430f3f8d7..c27353e548940 100755 --- a/build_tools/circle/build_test_arm.sh +++ b/build_tools/circle/build_test_arm.sh @@ -81,7 +81,6 @@ ccache -s --verbose mamba list -cp setup.cfg /tmp # Changing directory not to have module resolution use scikit-learn source # directory but to the installed package. cd /tmp diff --git a/conftest.py b/conftest.py index 74006980443bc..e4e478d2d72d7 100644 --- a/conftest.py +++ b/conftest.py @@ -4,6 +4,3 @@ # details. For example, this allows to build extensions in place and run pytest # doc/modules/clustering.rst and use sklearn from the local folder rather than # the one from site-packages. - -# This plugin is necessary to define the random seed fixture -pytest_plugins = ("sklearn.tests.random_seed",) diff --git a/sklearn/conftest.py b/sklearn/conftest.py index 766803cf2c56e..821b9c2044dbc 100644 --- a/sklearn/conftest.py +++ b/sklearn/conftest.py @@ -19,6 +19,7 @@ from sklearn.datasets import fetch_kddcup99 from sklearn.datasets import fetch_olivetti_faces from sklearn.datasets import fetch_rcv1 +from sklearn.tests import random_seed if parse_version(pytest.__version__) < parse_version(PYTEST_MIN_VERSION): @@ -245,3 +246,7 @@ def pytest_configure(config): matplotlib.use("agg") except ImportError: pass + + # Register global_random_seed plugin if it is not already registered + if not config.pluginmanager.hasplugin("sklearn.tests.random_seed"): + config.pluginmanager.register(random_seed) From d8433fd8610c360fb61c5c0fac7fe8594d3a8ada Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Tue, 29 Mar 2022 20:20:16 -0400 Subject: [PATCH 8/8] CI [cd build gh]