Skip to content

[python-package] Suppress confusing warning in dask module #6987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wohoef
Copy link

@wohoef wohoef commented Jul 30, 2025

This commit prevents UserWarning: Parameter n_jobs will be ignored. from being emitted each time a model is trained with the lightgbm.dask estimators.

The warning is now only shown if a user provides a specific, non-default value (neither None nor -1).

Fixes #6797

This commit prevents `UserWarning: Parameter n_jobs will be ignored.` from being emitted each time a model is trained with the `lightgbm.dask` estimators.

The warning is now only shown if a user provides a specific, non-default value (neither None nor -1).

Fixes microsoft#6797
@jameslamb jameslamb changed the title Fix: Suppress confusing warning in dask module [python-package] Suppress confusing warning in dask module Jul 30, 2025
@jameslamb jameslamb added the fix label Jul 30, 2025
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I support this change.

Please see one suggestion I left. In addition, can you please add tests confirming that the warning is raised and everything otherwise works in these situations?

You can use this as a reference:

def test_warns_and_continues_on_unrecognized_tree_learner(cluster):
with Client(cluster) as client:
X = da.random.random((1e3, 10))
y = da.random.random((1e3, 1))
dask_regressor = lgb.DaskLGBMRegressor(
client=client, time_out=5, tree_learner="some-nonsense-value", n_estimators=1, num_leaves=2
)
with pytest.warns(UserWarning, match="Parameter tree_learner set to some-nonsense-value"):
dask_regressor = dask_regressor.fit(X, y)
assert dask_regressor.fitted_

If you're not willing or able to add those tests, just @ me and I'd be happy to push some tests to your branch.

@wohoef
Copy link
Author

wohoef commented Jul 30, 2025

Thank you for the feedback James. I'll try to see if I can work on writing some tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[python-package] [dask] Dask estimators raise an unavoidable warning
2 participants