sknetwork-team / scikit-network

Graph Algorithms
Other
602 stars 67 forks source link

cython: linetrace=True causes TypeError: 'NoneType' object is not callable error #554

Closed mfojtak closed 1 year ago

mfojtak commented 1 year ago

Description

The presence of cython: linetrace=True in .pyx files causes TypeError: 'NoneType' object is not callable error when running in debug mode on VS Code.

What I Did

Debugging app which imports sknetwork
tbonald commented 1 year ago

Hi, Thanks for your feedback. The bug comes from Cython and can be corrected by an upgrade of numpy: https://stackoverflow.com/questions/72202926/during-debugging-pandas-gave-an-error-typeerror-nonetype-object-is-not-cal This is now on the Develop branch and will be available in the next release.

mfojtak commented 1 year ago

The problem persists in 0.30 The numpy issue has been fixed about a year ago.

What is the proper solution? Currently I have to maintain own version of scikit-network with the cython: linetrace=True line removed.

tbonald commented 1 year ago

OK, I've upgraded cython to 0.29.30, as recommanded by @QLutz (thanks). This should work now (on the develop branch). Thanks for the feedback.

mfojtak commented 1 year ago

That did not solve the problem. Tried multiple cython versions with no luck. Removing cython: linetrace=True is the only solution at the moment. Is this line necessary?

tbonald commented 1 year ago

Yes, it is necessary to run code coverage tools. We'll dig further. Thanks.

QLutz commented 1 year ago

I added on the relevant Cython issue (note also the related PR) that is open but stale. I have little hope that something will come out of it.

In the meanwhile you may try the fix referenced in the SO thread linked by @tbonald, i.e. building from source (possibly at some cost in terms of performance): CFLAGS="-DCYTHON_FAST_PYCALL=0" pip install --force-reinstall --no-binary numpy,scikit-network scikit-network numpy scipy although, I doubt it would work in this case.

mfojtak commented 1 year ago

The problematic line removal is still the only solution at the moment.

Would it be possible to remove the line using if statement based on env-variable or compiler switch? You can then use the line if needed for codecov tools and remove the line when compiling the final production pip package.

tbonald commented 1 year ago

Good suggestion! We'll explore this, thanks.