You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I've been working on a project which involves implementing reinforcement learning in a server-client app. The server is written in Java and the client is in Python, which is why I use JPype to import some server classes.
After importing the necessary packages and creating the environment using PettingZoo, it is time to create the model and train it using Stable-Baselines3, but the problem is that when I use Supersuit, it needs to pickle and unpickle the environment, and because the environment contains many Java objects, an error is thrown: TypeError: cannot pickle '_jpype._JField' object.
The normal Pickle package does not support JField objects, but in the JPype library, there is a JPickle version that supports JField objects. I tried to modify the cloudpickle_fast.py to add the JPickle package but I end up having a problem with the cloudpickle.loads()
Here is what I modified in cloudpickle_fast.py:
fromjpype.pickleimportJPickler, JUnpickler
defdump(self, obj):
try:
returnPickler.dump(self, obj)
exceptRuntimeErrorase:
if"recursion"ine.args[0]:
msg= (
"Could not pickle object as excessively deep recursion ""required."
)
raisepickle.PicklingError(msg) fromeelse:
raiseexceptTypeErrorase:
returnJPickler.dump(self, obj)
So, I've been working on a project which involves implementing reinforcement learning in a server-client app. The server is written in Java and the client is in Python, which is why I use JPype to import some server classes.
After importing the necessary packages and creating the environment using PettingZoo, it is time to create the model and train it using Stable-Baselines3, but the problem is that when I use Supersuit, it needs to pickle and unpickle the environment, and because the environment contains many Java objects, an error is thrown:
TypeError: cannot pickle '_jpype._JField' object
.The normal Pickle package does not support JField objects, but in the JPype library, there is a JPickle version that supports JField objects. I tried to modify the
cloudpickle_fast.py
to add the JPickle package but I end up having a problem with thecloudpickle.loads()
Here is what I modified in
cloudpickle_fast.py
:And here is the full stacktrace I get:
I don't have a lot of experience with Pickle, so any advice would be welcome, thanks.
The text was updated successfully, but these errors were encountered: