AcademySoftwareFoundation / OpenTimelineIO

Open Source API and interchange format for editorial timeline information.
http://opentimeline.io
Apache License 2.0
1.4k stars 276 forks source link

AnyDictionary and AnyVector don't support Box2d and V2d #1714

Open reinecke opened 3 months ago

reinecke commented 3 months ago

[x] I believe this isn't a duplicate topic
[x] This report is not related to an adapter

Select One:

[ ] Build problem
[x] Incorrect Functionality or bug
[ ] New feature or functionality

Description

Setting AnyDictionary or AnyVector values raises a TypeError. All OTIO serializable types should be usable for things like metadata dictionaries.

The fix should also test to make sure serialization and deserialization work properly.

Example:

>>> clip = otio.schema.Clip()
>>> clip.metadata["box"] = otio.schema.Box2d(otio.schema.V2d(0.0, 0.0), otio.schema.V2d(16.0, 9.0))
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.Box2d(min=otio.schema.V2d(x=0.0, y=0.0), max=otio.schema.V2d(x=16.0, y=9.0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 175, in __setitem__
    self.__internal_setitem__(key, _value_to_any(item))
                                   ^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.Box2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').

>>> clip.metadata["vector"] = otio.schema.V2d(16.0, 9.0)
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.V2d(x=16.0, y=9.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 175, in __setitem__
    self.__internal_setitem__(key, _value_to_any(item))
                                   ^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.V2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').

Optional


Environment

OpenTimelineIO: 0.15.0 PyPI Operating System: macOS 13.6.6 Python version if appropriate: Python 3.11.6

Reproduction Steps

d = otio._otio.AnyDictionary()
d["vector"] = otio.schema.V2d(16.0, 9.0)
d["box"] = otio.schema.Box2d(otio.schema.V2d(0.0, 0.0), otio.schema.V2d(16.0, 9.0))

vec = otio._otio.AnyVector()
vec.append(otio.schema.V2d(16.0, 9.0)
vec.append(otio.schema.Box2d(otio.schema.V2d(0.0, 0.0), otio.schema.V2d(16.0, 9.0)))

Log output if appropriate

>>> d = otio._otio.AnyDictionary()
>>> d["vec"] = otio.schema.V2d(16.0, 9.0)
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.V2d(x=16.0, y=9.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 175, in __setitem__
    self.__internal_setitem__(key, _value_to_any(item))
                                   ^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.V2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').
>>> d["box"] = otio.schema.Box2d(otio.schema.V2d(0.0, 0.0), otio.schema.V2d(16.0, 9.0))
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.Box2d(min=otio.schema.V2d(x=0.0, y=0.0), max=otio.schema.V2d(x=16.0, y=9.0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 175, in __setitem__
    self.__internal_setitem__(key, _value_to_any(item))
                                   ^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.Box2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').
>>> vec = otio._otio.AnyVector()
>>> vec.append(otio.schema.V2d(16.0, 9.0))
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.V2d(x=16.0, y=9.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen _collections_abc>", line 1078, in append
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 360, in insert
    index, conversion_func(item)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.V2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').
>>> vec.append(otio.schema.Box2d(otio.schema.V2d(0.0, 0.0), otio.schema.V2d(16.0, 9.0)))
Traceback (most recent call last):
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 112, in _value_to_any
    return PyAny(value)
           ^^^^^^^^^^^^
TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. opentimelineio._otio.PyAny(arg0: bool)
    2. opentimelineio._otio.PyAny(arg0: int)
    3. opentimelineio._otio.PyAny(arg0: float)
    4. opentimelineio._otio.PyAny(arg0: str)
    5. opentimelineio._otio.PyAny(arg0: None)
    6. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.SerializableObject)
    7. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.RationalTime)
    8. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeRange)
    9. opentimelineio._otio.PyAny(arg0: opentimelineio._opentime.TimeTransform)
    10. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyVector)
    11. opentimelineio._otio.PyAny(arg0: opentimelineio._otio.AnyDictionary)

Invoked with: otio.schema.Box2d(min=otio.schema.V2d(x=0.0, y=0.0), max=otio.schema.V2d(x=16.0, y=9.0))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen _collections_abc>", line 1078, in append
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 360, in insert
    index, conversion_func(item)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ereinecke/Projects/stash/vertical-video-example/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 115, in _value_to_any
    raise TypeError(
TypeError: A value of type '<class 'opentimelineio._otio.Box2d'>' is incompatible with OpenTimelineIO. OpenTimelineIO only supports the following value types in AnyDictionary containers (like the .metadata dictionary): ('int', 'float', 'str', 'bool', 'list', 'dictionary', 'opentime.RationalTime', 'opentime.TimeRange', 'opentime.TimeTransform', 'opentimelineio.core.SerializableObject').

Sample data and other attachements