question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash on «import lightgbm» if «--python-flag=no_docstrings»

See original GitHub issue

Let’s consider sample program using LightGBM and nuitka call for compilation on Linux:

https://github.com/belonesox/nuitka-light-gdm-troubles- branch «no_docstrings»

  • ./reproduce-me.sh to (re)install virtual environment for install/build/run compiled

Running results we get crush on «import lightgbm»

Traceback (most recent call last):
  File "/home/stas/projects/nuitka-wtf/nuitka-light-gdm-troubles/test-lightgbm.dist/test-lightgbm.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/stas/projects/nuitka-wtf/nuitka-light-gdm-troubles/test-lightgbm.dist/lightgbm/__init__.py", line 21, in <module lightgbm>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/stas/projects/nuitka-wtf/nuitka-light-gdm-troubles/test-lightgbm.dist/lightgbm/dask.py", line 1088, in <module lightgbm.dask>
  File "/home/stas/projects/nuitka-wtf/nuitka-light-gdm-troubles/test-lightgbm.dist/lightgbm/dask.py", line 1143, in DaskLGBMClassifier
AttributeError: 'NoneType' object has no attribute 'partition'

The problem option is «–python-flag=no_docstrings», without it all works fine. But why, if anyone wants to strip docstring…

Same problem exists even with nuitka factory.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Oct 26, 2022

People are often controlling behaviour with doc strings. Like automatically setting function defaults to the documentation, etc. and this might be a case. I will look at it.

Ultimately what might have to happen is that we white list some things, that must retain some doc strings. Question of course is how this code runs with pure Python and -O

0reactions
kayhayencommented, Oct 27, 2022

Well, Nuitka allows the second -O and the first -O to be separated, and gives no hint to what this needs, or when it will work or not. I am open however to anti-bloat measures for this. If you look at the code there, and believe the doc strings are only optional, you can patch it through user yaml files, and then of course we can integrate that in our standard config as well.

Eliminating doc strings seems very much worth it, not to speak of the obfuscucation parts of having them for your code.

As an enhancement, Nuitka probably needs to make it clear to the user, that it expects from the Python flags, that the original program already works with some options.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash without warning or error message when using Dataset ...
This crash happened both in the kaggle kernel and the local environment. Reproducible example. import pandas as pd import lightgbm as lgbm ...
Read more >
LightGBM FAQ — LightGBM 3.3.3.99 documentation
When running LightGBM on a large dataset, my computer runs out of RAM. 4. I am using Windows. ... I tried to use...
Read more >
Python crashes while running Light gbm with custom loss ...
The lightgbm model seems to be running when there is no custom loss function and I am just using the inbuilt rmse.
Read more >
Database Import Crash - Visual Studio Feedback
"Exception when processing duplicate elements" is thrown when importing Azure SQL database, and Visual Studio crashes. Import works when I create new solution ......
Read more >
How to Install Lightgbm on Windows? - GeeksforGeeks
Make the following import in your python terminal to verify if the installation has been done properly: import lightgbm.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found