Skip to content

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