Search - User list
Full Version: Python Object for attribute failed to deserialize
Root » PDG/TOPs » Python Object for attribute failed to deserialize
jamesr
Hi there,

I've got a PyObject attribute on a work item, which is a list of several instances of my own python object. I'd like to iterate over each of these objects in maya (they each hold some data about stuff to do, and I have some code running on the maya side to deal with them).

It works fine in Houdini if I inspect some of the attributes of the objects in the list with a Python Script TOP and have it print out to the terminal. But as soon as it hits the maya command chain portion, the log says "Python object for attribute 'components' failed to deserialize". ('components' is the work item attribute name). Is there anything I need to include in my Python objects to get them to deserialize properly?

Please excuse me if I haven't nailed all the terminology, I'm still getting started with PDG.

I searched the forums and couldn't really find a solution. Any insight would be greatly appreciated. Thanks!
Johan Boekhoven
There's a video, I think when PDG was released that goes into Maya/PDG. If I recall correctly that as soon as the server is running all python code is running in the PyMel env of Maya. So any special data you cary into maya will not just work out of the box I think. I'd say you need to convert the PyObject to something more basic before pushing it into maya server, like a basic dict or list.

Again never had to do it, so I might be way off.

edit : https://www.youtube.com/watch?v=t0bhiCoDR8M [www.youtube.com]
that's the video I had in mind, lot's of info on maya/pdg
chrisgreb
By default the PyObject attributes are serialized using `repr()` and deserialized using `eval()`. This means only simple objects that have compatible __repr__ output will automatically work.
jamesr
Thank you both for the quick replies!

Johan Boekhoven
I'd say you need to convert the PyObject to something more basic before pushing it into maya server, like a basic dict or list

Yeah, I think you might be right.


chrisgreb
This means only simple objects that have compatible __repr__ output will automatically work
Okay, that's sort of what I was thinking might be the case. I realized last night that I can actually do most of everything I need to do using the stock task operators (which is pretty sweet), so I think I will go that route instead.

Thanks again for the help!
matt_t
Chris - you mention this is the default behaviour, does that mean as users we are able to adjust this workflow? Perhaps using Pickle or some other similar serialisation module? I can imagine that would allow for even more flexibility when using command servers or PDGD.
chrisgreb
Indeed there is a hook to change the serialization:

https://www.sidefx.com/docs/houdini/tops/pdg/TypeRegistry.html#setPySerializationModule [www.sidefx.com]
matt_t
Great news! Thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB