Skip to content

Simplify reflect decorator - #8295

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
jcrist:reflect-reset-true-revert
Jun 29, 2026
Merged

Simplify reflect decorator#8295
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
jcrist:reflect-reset-true-revert

Conversation

@jcrist

@jcrist jcrist commented Jun 26, 2026

Copy link
Copy Markdown
Member

Now that all modules have been converted to the new ingest system, we can remove reflect(reset="type") and revert to reflect(reset=True) everywhere. The meaning of reflect(reset=True) is the old meaning of reflect(reset="type"), which was only around to let us migrate incrementally.

  • Renames reflect(reset="type") back to reflect(reset=True) everywhere.
  • Removes all handling of check_features in the reflect decorator.
  • Removes no longer needed cuml.accel path for handling list/tuple inputs in the reflect decorator. Those just work now, and don't require extra handling or duplicate conversion here.
  • Updates the ESTIMATOR_GUIDE.md to reflect these changes.

Part of #7428.

Now that all modules have been converted to the new ingest system, we
can remove `reflect(reset="type")` and revert to `reflect(reset=True)`
everywhere. The meaning of `reflect(reset=True)` is the old meaning of
`reflect(reset="type")`, which was only around to let us migrate
incrementally.

- Renames `reflect(reset="type")` -> `reflect(reset=True)` everywhere.
- Removes all handling of `check_features` in the `reflect` decorator.
- Removes no longer needed `cuml.accel` path for handling list/tuple
  inputs in the `reflect` decorator. Those just work now, and don't
  require extra handling or duplicate conversion here.
- Updates the `ESTIMATOR_GUIDE.md` to reflect these changes.
@jcrist jcrist self-assigned this Jun 26, 2026
@jcrist
jcrist requested a review from a team as a code owner June 26, 2026 04:43
@jcrist jcrist added the improvement Improvement / enhancement to an existing function label Jun 26, 2026
@jcrist
jcrist requested a review from betatim June 26, 2026 04:43
@jcrist jcrist added the non-breaking Non-breaking change label Jun 26, 2026
@github-actions github-actions Bot added the Cython / Python Cython or Python issue label Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 303ff314-8d76-4b52-8206-d7b5405895ea

📥 Commits

Reviewing files that changed from the base of the PR and between b4fd5fb and e342846.

📒 Files selected for processing (1)
  • python/cuml/cuml/__init__.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency in how fit/fit_transform/partial_fit/fit_predict and similar methods reset their state/output behavior across many estimators (including preprocessing, clustering, decomposition, linear models, neighbors, and SVMs), making results more predictable.
    • Tightened validation around output reset behavior, yielding clearer errors when misconfigured.
  • Documentation

    • Updated estimator development guidance and examples to follow the current reset configuration for fit-like methods.

Walkthrough

The pull request changes reflect so reset is boolean-only in the decorator implementation, updates many estimator decorators to use reset=True, and adjusts related tests, guide text, and package initialization.

Changes

Boolean reset rollout

Layer / File(s) Summary
Reflect contract update
python/cuml/cuml/internals/outputs.py
The reflect decorator documentation and runtime handling now treat reset as boolean-only, reject enabled reset when model or array is unset, and call _set_output_type(array_arg) inside the internal context.
Preprocessing decorators
python/cuml/cuml/_thirdparty/sklearn/preprocessing/*
Preprocessing estimators and third-party sklearn wrappers update fit-like @reflect and @cuml.internals.reflect decorators from reset="type" to reset=True.
Cluster, covariance, decomposition, and manifold decorators
python/cuml/cuml/cluster/*, python/cuml/cuml/covariance/*, python/cuml/cuml/decomposition/*, python/cuml/cuml/experimental/linear_model/lars.pyx, python/cuml/cuml/manifold/*
Clustering, covariance, decomposition, manifold, and Lars.fit update fit-like decorators to reset=True.
Linear-model, neighbor, solver, SVM, and related decorators
python/cuml/cuml/kernel_ridge/kernel_ridge.py, python/cuml/cuml/linear_model/*, python/cuml/cuml/multiclass/multiclass.py, python/cuml/cuml/neighbors/*, python/cuml/cuml/random_projection/random_projection.py, python/cuml/cuml/solvers/*, python/cuml/cuml/svm/*
Kernel ridge, linear-model, multiclass, neighbor, random-projection, solver, and SVM entry points update fit-like decorators to reset=True.
Tests, guide text, and package init
python/cuml/tests/test_reflection.py, wiki/python/ESTIMATOR_GUIDE.md, python/cuml/cuml/__init__.py
test_reflection.py updates the decorator configuration on the dummy estimators, ESTIMATOR_GUIDE.md changes the fit-like examples and guidance text to reset=True, and python/cuml/cuml/__init__.py imports cuml.accel during initialization.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • rapidsai/cuml#7642: Both PRs update the Python estimator/developer docs to reflect current @reflect reset guidance.
  • rapidsai/cuml#7894: Both PRs modify @reflect(..., reset=...) behavior in python/cuml/cuml/internals/outputs.py.
  • rapidsai/cuml#8052: Both PRs touch overlapping @reflect(reset=...) sites in preprocessing estimators.

Suggested reviewers

  • viclafargue
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change to the reflect decorator.
Description check ✅ Passed The description matches the changeset and correctly summarizes the reflect reset migration and decorator cleanup.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/cuml/cuml/internals/outputs.py`:
- Around line 461-476: The `reflect` decorator’s `reset` handling in
`outputs.py` still accepts truthy non-boolean values, so the bool-only contract
is not enforced. Add explicit validation in the `reflect` wrapper before `inner`
is defined to reject any `reset` value that is not a `bool`, and keep the
existing `model is None or array is None` validation for the true case. Use the
`reflect` function and its `reset` parameter as the main touchpoints so invalid
call sites like `reset="type"` fail immediately.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7e230d66-2320-4bc4-8393-52033be52a84

📥 Commits

Reviewing files that changed from the base of the PR and between e93fc90 and b4fd5fb.

📒 Files selected for processing (45)
  • python/cuml/cuml/_thirdparty/sklearn/preprocessing/_column_transformer.py
  • python/cuml/cuml/_thirdparty/sklearn/preprocessing/_data.py
  • python/cuml/cuml/_thirdparty/sklearn/preprocessing/_discretization.py
  • python/cuml/cuml/_thirdparty/sklearn/preprocessing/_function_transformer.py
  • python/cuml/cuml/_thirdparty/sklearn/preprocessing/_imputation.py
  • python/cuml/cuml/cluster/agglomerative.pyx
  • python/cuml/cuml/cluster/dbscan.pyx
  • python/cuml/cuml/cluster/hdbscan/hdbscan.pyx
  • python/cuml/cuml/cluster/kmeans.pyx
  • python/cuml/cuml/cluster/spectral_clustering.pyx
  • python/cuml/cuml/covariance/empirical_covariance.py
  • python/cuml/cuml/covariance/ledoit_wolf.py
  • python/cuml/cuml/decomposition/incremental_pca.py
  • python/cuml/cuml/decomposition/pca.pyx
  • python/cuml/cuml/decomposition/tsvd.pyx
  • python/cuml/cuml/experimental/linear_model/lars.pyx
  • python/cuml/cuml/internals/outputs.py
  • python/cuml/cuml/kernel_ridge/kernel_ridge.py
  • python/cuml/cuml/linear_model/elastic_net.py
  • python/cuml/cuml/linear_model/linear_regression.pyx
  • python/cuml/cuml/linear_model/logistic_regression.py
  • python/cuml/cuml/linear_model/mbsgd_classifier.py
  • python/cuml/cuml/linear_model/mbsgd_regressor.py
  • python/cuml/cuml/linear_model/ridge.pyx
  • python/cuml/cuml/manifold/spectral_embedding.pyx
  • python/cuml/cuml/manifold/t_sne.pyx
  • python/cuml/cuml/manifold/umap/umap.pyx
  • python/cuml/cuml/multiclass/multiclass.py
  • python/cuml/cuml/neighbors/kernel_density.pyx
  • python/cuml/cuml/neighbors/kneighbors_classifier.pyx
  • python/cuml/cuml/neighbors/kneighbors_regressor.pyx
  • python/cuml/cuml/neighbors/nearest_neighbors.pyx
  • python/cuml/cuml/preprocessing/_label.py
  • python/cuml/cuml/preprocessing/_target_encoder.py
  • python/cuml/cuml/preprocessing/label.py
  • python/cuml/cuml/random_projection/random_projection.py
  • python/cuml/cuml/solvers/cd.pyx
  • python/cuml/cuml/solvers/qn.pyx
  • python/cuml/cuml/solvers/sgd.pyx
  • python/cuml/cuml/svm/linear_svc.py
  • python/cuml/cuml/svm/linear_svr.py
  • python/cuml/cuml/svm/svc.py
  • python/cuml/cuml/svm/svr.py
  • python/cuml/tests/test_reflection.py
  • wiki/python/ESTIMATOR_GUIDE.md

Comment thread python/cuml/cuml/internals/outputs.py
We previously were implicitly always exposing this namespace. For now
lets keep doing it - it's not expensive to import (relative to other
things).

@csadorf csadorf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jcrist

jcrist commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

/merge

@rapids-bot
rapids-bot Bot merged commit 2469a7b into NVIDIA:main Jun 29, 2026
93 of 94 checks passed
@jcrist
jcrist deleted the reflect-reset-true-revert branch June 29, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants