Skip to content
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

[dask] add tests on warnings, fix incorrect variable in log #3865

Merged
merged 2 commits into from
Jan 27, 2021

Conversation

jameslamb
Copy link
Collaborator

While working on #3756 , I've been running mypy python-package/. This caught a bug in my refactoring from recent PRs (not sure which one).

python-package/lightgbm/dask.py:251: error: Name 'tree_learner' is not defined

This PR fixes that, and adds unit tests to cover the behavior under the two warnings in lightgbm.dask._train().

@StrikerRUS
Copy link
Collaborator

I've been running mypy python-package/.

Could you please setup mypy in lint task but allow it to fail (|| exit 0) so that everyone will be able to see logs and possibly prevent new issues to appear. We had the same strategy with cpplint. We had been checking logs manually but at some moment we simply removed || exit 0.

if [[ $TASK == "lint" ]]; then

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Thanks! Just one proposal for even more informative name.

tests/python_package_test/test_dask.py Outdated Show resolved Hide resolved
dask_regressor = dask_regressor.fit(X, y, client=client)

assert dask_regressor.fitted_
assert dask_regressor.get_params()['tree_learner'] == tree_learner
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wonder: is it possible to access params via attributes like it can be done in sklearn-wrapper?

dask_regressor.tree_learner

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe! I haven't tested. I didn't actually know the sklearn interface supported that.

But either way, I have a preference for get_params() here because it also gives us some confidence that this is working:

self.set_params(**model.get_params())
self._copy_extra_params(model, self)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Exactly set_params() should set attributes btw

def set_params(self, **params):
"""Set the parameters of this estimator.
Parameters
----------
**params
Parameter names with their new values.
Returns
-------
self : object
Returns self.
"""
for key, value in params.items():
setattr(self, key, value)
if hasattr(self, '_' + key):
setattr(self, '_' + key, value)
self._other_params[key] = value
return self

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
@jameslamb
Copy link
Collaborator Author

I've been running mypy python-package/.

Could you please setup mypy in lint task but allow it to fail (|| exit 0) so that everyone will be able to see logs and possibly prevent new issues to appear. We had the same strategy with cpplint. We had been checking logs manually but at some moment we simply removed || exit 0.

if [[ $TASK == "lint" ]]; then

sure! Sounds like an excellent good first issue idea for people to fix warnings.

@jameslamb jameslamb merged commit d4658fb into microsoft:master Jan 27, 2021
@jameslamb jameslamb deleted the fix/tree-learner-log branch January 27, 2021 04:10
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants