-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[python][scikit-learn] change MRO #3192
Conversation
@henry0312 Do you have any ideas why changing base classes order causes Sphinx to fail? To be honest, I'm out of ideas... |
@StrikerRUS this is blocked by the unexpected error? |
@guolinke Surprisingly, changing the order of parent classes causes that Sphinx cannot build the documentation for the whole Python API. I spent two days digging this problem but unfortunately didn't find any ideas why it happens. |
I remember @hayesall was very experienced in Sphinx and helped us a lot with Python docs config some time ago. May we ask you @hayesall to take a look at the current issue? Thanks in advance! |
I spent a little time trying this this morning too. Couldn't get to a root cause, but I can add the specific error message here since I think that might help. After the changes in this PR, running
But |
Yes, the exact error can be seen in CI logs: |
Hey @jameslamb, I saw your tweet. This error message is a confusing one but something like that happens whenever sphinx-autodoc can't import the package for some reason. Simplifying a lot, it tries stuff like this: from sphinx.ext.autodoc.importer import import_module
try:
thing = getattr(import_module("lightgbm"), "Booster")
except Exception:
pass
try:
thing = import_module("lightgbm.Booster")
except Exception:
raise <unhelpful_error> and when that fails it raises your error, suppressing the traceback of the actual reason why it can't import it. Perhaps you could try inserting a line in your CI script right before python -c 'from sphinx.ext.autodoc.importer import import_module; print(getattr(import_module("lightgbm"), "Booster"))' and see if that prints a more helpful error message? |
@austin3dickey thanks for the suggestion! That helped, and in a way that might surprise you. Running this didn't fail python -c 'from sphinx.ext.autodoc.importer import import_module; print(getattr(import_module("lightgbm"), "Dataset"))' But what it printed gave me a hint
This told me that maybe the problem was that somehow sphinx couldn't see Long story short, I tried a bunch of things and eventually was able to get past these errors by changing all the entries in https://github.com/microsoft/LightGBM/blob/master/docs/Python-API.rst to this: .. autosummary::
:toctree: pythonapi/
.. autosummary:: Dataset
.. autosummary:: Booster
.. autosummary:: CVBooster This then showed me what I think the "real" error is:
I'm not sure what to do yet, but that at least is a more informative error than the one we were getting from sphinx originally! |
@StrikerRUS Has the problem been solved. Is possible that this is due to the import error of sklearn? Because I've observe the following in my local VSCode environment. Above is just a guess from simple trial-and-error. |
@shiyu1994 Brilliant investigation! This helps a lot! I guess that Lines 40 to 44 in d517ba1
|
Finally got a chance to work on this. The thing was in that in case of scikit-learn unavailability Thanks a lot to all participants! @shiyu1994 Your investigation was great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this, @StrikerRUS ! I'm very glad to see this merged 😀 |
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. |
Refer to