Skip to content

Commit a968288

Browse files
authored
Mark sklearn tests (#1202)
* Add sklearn marker * Mark tests that use scikit-learn * Only run scikit-learn tests multiple times The generic tests that don't use scikit-learn should only be tested once (per platform). * Rename for correct variable * Add sklearn mark for filesystem test * Remove quotes around sklearn * Instead include sklearn in the matrix definition * Update jobnames * Add explicit false to jobname * Remove space * Add function inside of expression? * Do string testing instead * Add missing ${{ * Add explicit true to old sklearn tests * Add instruction to add pytest marker for sklearn tests
1 parent d9850be commit a968288

File tree

10 files changed

+126
-3
lines changed

10 files changed

+126
-3
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ on: [push, pull_request]
44

55
jobs:
66
test:
7-
name: (${{ matrix.os }}, Py${{ matrix.python-version }}, sk${{ matrix.scikit-learn }})
7+
name: (${{ matrix.os }}, Py${{ matrix.python-version }}, sk${{ matrix.scikit-learn }}, sk-only:${{ matrix.sklearn-only }})
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
1111
python-version: [3.6, 3.7, 3.8]
1212
scikit-learn: [0.21.2, 0.22.2, 0.23.1, 0.24]
1313
os: [ubuntu-latest]
14+
sklearn-only: ['true']
1415
exclude: # no scikit-learn 0.21.2 release for Python 3.8
1516
- python-version: 3.8
1617
scikit-learn: 0.21.2
@@ -19,17 +20,22 @@ jobs:
1920
scikit-learn: 0.18.2
2021
scipy: 1.2.0
2122
os: ubuntu-latest
23+
sklearn-only: 'true'
2224
- python-version: 3.6
2325
scikit-learn: 0.19.2
2426
os: ubuntu-latest
27+
sklearn-only: 'true'
2528
- python-version: 3.6
2629
scikit-learn: 0.20.2
2730
os: ubuntu-latest
31+
sklearn-only: 'true'
2832
- python-version: 3.8
2933
scikit-learn: 0.23.1
3034
code-cov: true
35+
sklearn-only: 'false'
3136
os: ubuntu-latest
3237
- os: windows-latest
38+
sklearn-only: 'false'
3339
scikit-learn: 0.24.*
3440
fail-fast: false
3541
max-parallel: 4
@@ -62,7 +68,10 @@ jobs:
6268
if: matrix.os == 'ubuntu-latest'
6369
run: |
6470
if [ ${{ matrix.code-cov }} ]; then codecov='--cov=openml --long --cov-report=xml'; fi
65-
pytest -n 4 --durations=20 --timeout=600 --timeout-method=thread --dist load -sv $codecov --reruns 5 --reruns-delay 1
71+
# Most of the time, running only the scikit-learn tests is sufficient
72+
if [ ${{ matrix.sklearn-only }} = 'true' ]; then sklearn='-m sklearn'; fi
73+
echo pytest -n 4 --durations=20 --timeout=600 --timeout-method=thread --dist load -sv $codecov $sklearn --reruns 5 --reruns-delay 1
74+
pytest -n 4 --durations=20 --timeout=600 --timeout-method=thread --dist load -sv $codecov $sklearn --reruns 5 --reruns-delay 1
6675
- name: Run tests on Windows
6776
if: matrix.os == 'windows-latest'
6877
run: | # we need a separate step because of the bash-specific if-statement in the previous one.

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ following rules before you submit a pull request:
153153

154154
- Add [unit tests](https://github.com/openml/openml-python/tree/develop/tests) and [examples](https://github.com/openml/openml-python/tree/develop/examples) for any new functionality being introduced.
155155
- If an unit test contains an upload to the test server, please ensure that it is followed by a file collection for deletion, to prevent the test server from bulking up. For example, `TestBase._mark_entity_for_removal('data', dataset.dataset_id)`, `TestBase._mark_entity_for_removal('flow', (flow.flow_id, flow.name))`.
156-
- Please ensure that the example is run on the test server by beginning with the call to `openml.config.start_using_configuration_for_example()`.
156+
- Please ensure that the example is run on the test server by beginning with the call to `openml.config.start_using_configuration_for_example()`.
157+
- Add the `@pytest.mark.sklearn` marker to your unit tests if they have a dependency on scikit-learn.
157158

158159
- All tests pass when running `pytest`. On
159160
Unix-like systems, check with (from the toplevel source folder):

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ def pytest_sessionfinish() -> None:
174174
logger.info("{} is killed".format(worker))
175175

176176

177+
def pytest_configure(config):
178+
config.addinivalue_line("markers", "sklearn: marks tests that use scikit-learn")
179+
180+
177181
def pytest_addoption(parser):
178182
parser.addoption(
179183
"--long",

0 commit comments

Comments
 (0)