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

Working with JPickler #1097

Open
dg-deus opened this issue Nov 7, 2024 · 2 comments
Open

Working with JPickler #1097

dg-deus opened this issue Nov 7, 2024 · 2 comments

Comments

@dg-deus
Copy link

dg-deus commented Nov 7, 2024

Let's say I have data of dict type, and the data consists of various types including RapidWright objects like PIP.

And I tried to pickle/serialize the dict-type data, but failed.

from jpype.pickle import JPickler
with open('myData.pickle', 'wb') as f:
  JPickler(f).dump(my_dict)

The code fails with the following error:
java.lang.java.lang.InternalError: java.lang.InternalError: java.io.InvalidClassException: com.xilinx.rapidwright.device.PIP; imcompatible types for field a

RapidWright does not support JPickler?
Thank you in advance

@clavin-xlnx
Copy link
Member

Thanks for pointing this out, it looks like "Pickling of Java objects is restricted to classes that implement Serializable." according to the docs (https://jpype.readthedocs.io/en/latest/api.html?jpype-pickle-module=#jpype-pickle-module).

It looks like most classes in RapidWright implement Serializable, but there are some that do not. This inconsistency could be resolved in the next release as it is not a significant change to make. However, if JPickler is using the Java Serializable interface, it might not produce very efficient results/performance.

@clavin-xlnx
Copy link
Member

I've attempted to update the rest of the RapidWright classes to implement Serializable, but I still can't get JPickler to work. It is now complaining that java.lang.Object does not implement Serializable. I'm not sure if there is any easy fix at this point.

Unfortunately, the Serializable interface in Java is not very performant and we don't typically use it.

I tried using Kryo (which is bundled with RapidWright) as a Java serialization solution, but had issues with it as well as it requires all classes to have a no-arg constructor. I'm afraid I don't have a good automatic solution for serializing Java objects at the moment, and there would certainly be some work to integrate it to work correctly with Python.

Can you share a bit more about what you are trying to accomplish? Perhaps we can help you better find an alternative solution.

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

2 participants