The original intention was to be able to do this with dynamically
discovered messages for which you have the as set of *_pb2.py objects but
don't know in advance which one you'll need to instantiate and set the
fields for
assuming your **args contains keys and values for all of the required
The real solution seems to be to build the objects from the bottom up.
What's going on is that nested messages are "immmutable" objects from the
point of view of their parent object. You can't just set them from the top
down, but you can build the object from the bottom up. The error messages
One other thing I am now trying is to take the task_instance object and
call SerializeToString() on it, then use
task_info_instance.MergeFromString(serialized_task_instance)
this is not raising any exception and does seem to be setting the field,
but I'm not entirely convinced yet
On Friday,
I’m trying to dynamically create objects from discovery of pb2 generated
protobuf files and assign appropriate values to their fields. If the field
types are simple, this is straightforward - e.g. for TYPE_BOOL,
setattr(obj, “field_name”, True) works fine - but if the field is
TYPE_MESSAGE,