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

Disallow importing non-dask estimators from xgboost.dask #7133

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

gforsyth
Copy link
Contributor

This is mostly a style change, but also avoids a user error (that I have
committed on a few occasions). Since XGBRegressor and XGBClassifier
are imported as parent classes for the dask estimators, without
defining an __all__, autocomplete (or muscle) memory will produce the
following with little prompting:

from xgboost.dask import XGBClassifier

There's nothing inherently wrong with that, but given that
XGBClassifier is not dask enabled, it can lead to confusing behavior
until you figure out you should've typed

from xgboost.dask import DaskXGBClassifier

Another option is to alias import the existing non-dask estimators.

This is mostly a style change, but also avoids a user error (that I have
committed on a few occasions).  Since `XGBRegressor` and `XGBClassifier`
are imported as parent classes for the `dask` estimators, without
defining an `__all__`, autocomplete (or muscle) memory will produce the
following with little prompting:

```
from xgboost.dask import XGBClassifier
```

There's nothing inherently wrong with that, but given that
`XGBClassifier` is not `dask` enabled, it can lead to confusing behavior
until you figure out you should've typed

```
from xgboost.dask import DaskXGBClassifier
```

Another option is to alias import the existing non-dask estimators.
@trivialfis trivialfis self-requested a review July 27, 2021 14:07
python-package/xgboost/dask.py Outdated Show resolved Hide resolved
python-package/xgboost/dask.py Outdated Show resolved Hide resolved
python-package/xgboost/dask.py Show resolved Hide resolved
@gforsyth
Copy link
Contributor Author

Ready for another look @trivialfis

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR!

@trivialfis trivialfis merged commit 92ae3ab into dmlc:master Jul 27, 2021
@gforsyth gforsyth deleted the limit_xgbdask_imports branch July 27, 2021 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants