Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Document local pytest workflows in the Python developer guide
  • Loading branch information
csadorf committed Nov 18, 2026
commit 9632c60bcdc70f1e2d9fd916b6a052f95e567435
37 changes: 6 additions & 31 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,8 @@ If you want a list of the available C++ tests:
$ ctest --test-dir cpp/build -N
```

To run all Python tests, including multi-GPU algorithms, from the repo root:
```bash
$ cd python
$ pytest -v
```

To run only single-GPU algorithm tests:

```bash
$ pytest --ignore=cuml/tests/dask --ignore=cuml/tests/test_nccl.py
```

If you want a list of the available Python tests:
```bash
$ pytest cuml/tests --collect-only
```

**Note:** Some tests require `xgboost`. If running tests in conda devcontainers, you must install the `xgboost` conda package manually. See `dependencies.yaml` for version information.
For Python tests and focused local test execution, see
[Running Tests](docs/source/developer_guide/python/development.md#running-tests).

### Manual Process

Expand Down Expand Up @@ -236,23 +220,14 @@ From the repository root:
$ python -m pip install --no-build-isolation --no-deps --config-settings rapidsai.disable-cuda=true python/cuml
```

To run Python tests (optional):

```bash
$ cd python
$ pytest -v
```

To run only single-GPU algorithm tests:
To run Python tests from the repository root:

```bash
$ pytest --ignore=cuml/tests/dask --ignore=cuml/tests/test_nccl.py
pytest -v
```

If you want a list of the available tests:
```bash
$ pytest cuml/tests --collect-only
```
See the [developer testing guide](docs/source/developer_guide/python/development.md#running-tests)
for focused selections and other suites.

### Custom Build Options

Expand Down
1 change: 0 additions & 1 deletion ci/tests/test_pytest_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,3 @@ def test_runner_preserves_arguments_and_cwd(tmp_path, runner):
assert lines[1:5] == ["-m", "pytest", "-c", str(REPO / "pyproject.toml")]
assert lines[-3:] == ["some path/test_file.py::test_one", "-k", "a or b"]
assert "." not in lines

52 changes: 39 additions & 13 deletions docs/source/developer_guide/python/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def function_name(param1, param2):
For more details, refer to the [NumPy docstring style guide](https://numpydoc.readthedocs.io/en/stable/format.html).

## Testing and Unit Testing
We use [pytest](https://docs.pytest.org/en/latest/) for writing and running tests. To see existing examples, refer to any of the `test_*.py` files in the folder `cuml/tests`.
We use [pytest](https://docs.pytest.org/en/latest/) for writing and running tests. To see existing examples, refer to any of the `test_*.py` files in the folder `python/cuml/tests`.

### Test Organization
- Keep all tests for a single estimator in one file, with exceptions for:
Expand Down Expand Up @@ -235,24 +235,50 @@ Control via these pytest options:
- Document test assumptions and requirements

### Running Tests
Build from the repository root. Run Python tests from `python/cuml/` or one of its subdirectories so pytest picks up the package configuration.

Activate the development environment and rebuild changed code before testing.
Run `pytest` from the repository root or any of its subdirectories. The following
examples use paths relative to the repository root:

```bash
# From the repository root
./build.sh
pytest # Run the standard single-GPU Python test suite
pytest -k kmeans # Run tests matching "kmeans"
# Select test targets directly:
pytest python/cuml/tests/test_kmeans.py
pytest python/cuml/tests/test_kmeans.py::test_kmeans_transform_euclidean
pytest --collect-only # List the default suite without running it
```

Refine the selection with standard pytest options such as `-k`, or provide test
files, directories, or test IDs directly. Paths are relative to your current
working directory; explicit targets replace the suite's default selection.

# Then run Python tests
cd python/cuml
python -m pytest # Run all configured Python tests
#### Selecting a suite

The default suite, `standard`, runs cuML's single-GPU Python tests. Select other
suites with `--cuml-suite`:

```bash
pytest --cuml-suite=dask # Requires Dask dependencies
pytest --cuml-suite=accel # cuML accelerator tests
pytest --cuml-suite=cudf-pandas # Standard tests with cudf.pandas
```

Common options:
- `python -m pytest cuml/tests/test_kmeans.py` - Run a specific file
- `python -m pytest -k "test_kmeans"` - Run tests matching a pattern
- `python -m pytest --run_unit` - Run only unit tests
- `python -m pytest -v` - Verbose output
Explicit test paths retain the selected suite's execution configuration.
Add `--quick_run` to reduce parameter combinations for a shorter correctness run.

#### Test-runner regression tests

The runner regression tests run in the dedicated `local-runner-tests` CPU job
on every PR CI run, independently of cuML builds. JUnit results are retained in
the job's additional artifacts, including on test failure. Run them locally with:

```bash
python -m pytest ci/tests
```

Running pytest from outside `python/cuml/` can result in import errors or missed pytest configuration.
Some tests require `xgboost`. If using a conda devcontainer, install the `xgboost`
conda package manually; see `dependencies.yaml` for version information.

## Python-defined kernels

Expand Down
Loading