Should OTIO_SCHEMA key inside metadata result in a SerializableObject? #1230
-
I noticed this somewhat by accident, but if OTIO_SCHEMA exists inside a metadata object the OTIO API will attempt to deserialize it into a schema. I was wondering if wondering if this was an unintentional side effect of the recursive deserialization or if the metadata is not intended to not be a completely opaque blob? One thing to note is that if there is no schema available in the manifest matching the OTIO_SCHEMA value, the metadata will include an UnknownSchema when read through the API. Here's an example snippet of serialized data (with only relevant fields included):
If I access this in the API:
This prevents the metadata from being accessed like a regular dictionary object, for example I am not sure if this is desirable or not, so I thought it would be good to have a discussion about it. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
My initial thought is that this is not desirable. I reckon anything inside a metadata object should be be treated as opaque by OTIO, otherwise there's scope for all sorts of unexpected and inconsistent behaviour. Perhaps, if they really want to, client could still choose to extract such embedded schema and feed it into OTIO deserialization? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! Let's poke some of the experts to see if they also have an opinion @jminor @reinecke @ssteinbach |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry for the brief answer while I'm out on leave, but yes, this is intentional. The idea is/was that custom schema objects may exist within metadata, and the schema system gives those objects the benefit of the schema upgrade system, serialization to/from class instances with helpful methods, etc. We have been using this in our pipeline for a while with some pros & cons. The main con being that there isn't an established SchemaDef mechanism in pure C++. However, it is pretty easy to register custom classes in C++ even if there isn't a plugin mechanism for that. You can just subclass The other downside, which you mentioned is that UnknownSchema objects are opaque, which makes them awkward to work with if you haven't provided a custom class. It might be desirable to allow accessing them like dictionaries, or maybe just an accessor on the internal dictionary that they use to store their contents. |
Beta Was this translation helpful? Give feedback.
-
Thanks for answering even while on leave Josh! I agree it could be a nice enhancement to allow someway of accessing an UnknownSchema like a dictionary. But at least until then it still has an accessor where the raw json can be extracted. |
Beta Was this translation helpful? Give feedback.
Hi, sorry for the brief answer while I'm out on leave, but yes, this is intentional. The idea is/was that custom schema objects may exist within metadata, and the schema system gives those objects the benefit of the schema upgrade system, serialization to/from class instances with helpful methods, etc.
We have been using this in our pipeline for a while with some pros & cons. The main con being that there isn't an established SchemaDef mechanism in pure C++. However, it is pretty easy to register custom classes in C++ even if there isn't a plugin mechanism for that. You can just subclass
SerializableObjectWithMetadata
and then callTypeRegistry::register_type(...)
before deserializing and…