ninia / jep

Embed Python in Java
Other
1.3k stars 147 forks source link

Exception while executing a model - jep.JepException: <class 'BufferError'>: scalar buffer is readonly #372

Closed pvb05 closed 1 year ago

pvb05 commented 2 years ago

Hi,

I have a Python 3.6 example model which I am executing using Jep 4.0.1 APIs. I am instantiating a Subinterpreter to execute the model function but seeing the following error.

jep.JepException: <class 'BufferError'>: scalar buffer is readonly at jep.Jep.invoke(Native Method) ~[jep-4.0.1.jar:?] at jep.Jep.invoke(Jep.java:257) ~[jep-4.0.1.jar:?]

The same model worked fine in Jep 3.8.2. Can someone help me on what might be the reason for the failure?

Environment (please complete the following information):

ndjensen commented 2 years ago

BufferError is not coming out of Jep, I think it's coming out of numpy. Are you sure you're using the same version of Python and same version of numpy as before?

pvb05 commented 2 years ago

Hi ndjensen, No, I rebuilt the model example for new version of Python and numpy. If I make use of Jep 3.9.1 it works fine.

bsteffensmeier commented 2 years ago

Can you provide any sample code so we can recreate your problem or even examples of how you are passing data between python and java. The only code that impacts buffers that I am aware of in 4.0.1 allows passing python buffer objects to java and converting them to arrays automaticalyl. This would only impact you if you are using python buffer objects that are not numpy arrays and I would expect more problems from java than python if this was the case but if you are going back and forth alot this may impact you.

bsteffensmeier commented 2 years ago

I believe this is a duplicate of #373 which has a repeatable test case. If you can, consider testing the change in the #374 against your specific use case and verify it fixes your problem.

ndjensen commented 2 years ago

@PradeepBadiger, the newly released Jep 4.0.2 has @bsteffensmeier's fix for buffers. Please try that release and let us know if it fixes your problem.

pvb05 commented 2 years ago

@ndjensen - Thank you very much. I will check this out and let your know if it fixes the issue.

bsteffensmeier commented 1 year ago

Closing due to inactivity