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

Encountering numba current locale errors? #28

Closed
vinayprabhu opened this issue Nov 28, 2017 · 11 comments
Closed

Encountering numba current locale errors? #28

vinayprabhu opened this issue Nov 28, 2017 · 11 comments

Comments

@vinayprabhu
Copy link

`raise NotImplementedError("cannot convert native %s to Python object" % (typ,))
LoweringError: cannot convert native const('\tnn descent iteration ') to Python object
File "../../../../home/.local/lib/python2.7/site-packages/umap/umap_.py", line 663
[1] During: lowering "print($515.5)" at /home/.local/lib/python2.7/site-packages/umap/umap_.py (663)

Failed at nopython (nopython mode backend)
cannot convert native const('\tnn descent iteration ') to Python object
File "../../../../home/.local/lib/python2.7/site-packages/umap/umap_.py", line 663
[1] During: lowering "print($515.5)" at /home/.local/lib/python2.7/site-packages/umap/umap_.py (663)
`
Related to 1.12.3.3 here: http://numba.pydata.org/numba-doc/dev/user/faq.html

@lmcinnes
Copy link
Owner

Wow, good catch! Thanks for the reference -- it saved me an evening of (probably very frustrating) googling. I think I have it fixed, but I would greatly appreciate it if you can test on your system (if you have time) to ensure that it does indeed resolve the issue for you. Thanks!

@MSiam
Copy link

MSiam commented Nov 28, 2017

I am encountering the same exact error even after your change.

@lmcinnes
Copy link
Owner

If that's the case then I must admit I am really not sure what the correct fix is -- this involves numba internals which I am not familiar with. I'll have to try and ask numba developers what the right solution to this is, which unfortunately may take a while. As an interim solution you can check out the code and simply remove or comment out code blocks

if verbose:
    print(...)

Ultimately I would prefer a more complete solution though, as the progress logging is really quite useful.

@sauln
Copy link
Collaborator

sauln commented Nov 29, 2017

This is strange. I could try changing the prints to the logging module, but it looks like the problem comes during a string conversion, not the print function.

Does this happen always with python 2.7? Is there a formula for recreating the issue so I can play around with it?

@MSiam
Copy link

MSiam commented Nov 29, 2017

I am using python2.7 yes. I just ran the examples/digits/digits.py code nothing from my side and it gave this error:

raise NotImplementedError("cannot convert native %s to Python object" % (typ,))
LoweringError: cannot convert native const('\tnn descent iteration ') to Python object
File "build/bdist.linux-x86_64/egg/umap/umap_.py", line 455
[1] During: lowering "print($515.5)" at build/bdist.linux-x86_64/egg/umap/umap_.py (455)

Failed at nopython (nopython mode backend)
cannot convert native const('\tnn descent iteration ') to Python object
File "build/bdist.linux-x86_64/egg/umap/umap_.py", line 455
[1] During: lowering "print($515.5)" at build/bdist.linux-x86_64/egg/umap/umap_.py (455)

Thanks removing the if verbose, made it work.

@lmcinnes
Copy link
Owner

I suspect the logging module will not play nicely with numba; perhaps this is a python2/python3 compatability issue related to the print function? @sauln if you have some time to look into this I would greatly appreciate it as I don't have a lot of time for the next week or so.

@sauln
Copy link
Collaborator

sauln commented Nov 29, 2017

I think it's some combination of print statements and string operations in python 2.

Multiple print arguments like

print("hello", "world")

cause the error and I haven't figured out any other way to format strings in numba.

This issue talks briefly about numba+print, but it was closed without explicit resolution.

I haven't found any way around this problem. There might be something in the numba documentation, but nothing has come up from google searches. I'll try to dig a bit more into this tomorrow.

@lmcinnes
Copy link
Owner

Thanks Nathaniel, at least we know what the likely issue is. One possibility is to use cffi and get the printf function from C to do the formatted printing, but that adds an extra dependency on cffi. Another option would be to explicitly write a very constrained function to do the limited format of printing we need and call that instead. I would welcome other ideas as neither of those seem optimal.

@sauln
Copy link
Collaborator

sauln commented Nov 29, 2017

It might be hacky, but it should be possible to require cffi only for python2.7. That would force maintenance of two different logging systems though. As a first step, it's probably easiest to disable all logging on 2.7.

What do you think about having different behavior for 2.7 and 3? It's not ideal, but at least that way, 3+ could have complete and pretty logging.

@lmcinnes
Copy link
Owner

lmcinnes commented Nov 29, 2017 via email

@sauln
Copy link
Collaborator

sauln commented Nov 29, 2017

I’ll look into it tonight.

lmcinnes added a commit that referenced this issue Nov 30, 2017
fix #28, issues with print in version 2.7
sauln pushed a commit to sauln/umap that referenced this issue Nov 30, 2017
sauln pushed a commit to sauln/umap that referenced this issue Nov 30, 2017
sauln pushed a commit that referenced this issue Nov 30, 2017
Integration tests should run w/o conda also.

Also, the fix for #28 did not make it into the sparse matrix file.
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

No branches or pull requests

4 participants