Skip to content

Commit ef70835

Browse files
ssteinbachmeshula
authored andcommitted
Schema Downgrading System (AcademySoftwareFoundation#1387)
* refactor versioning tests into their own class * DRY cleanup in the serializer before other stuff * DRY reduction in the json FILE serializer * Add io_perf_test to repo * Add a call w/ downgrade manifest to io_perf_test * add anydictionary convenience functions * add .cache to gitignore * add override tags * add perf tests for no-downgrade scenarios * autogen version info struct * add exceptions for overwriting up/downgrade fn * add exception when double registering a type * move schema version types into typeRegistry * add version manifest plugin * lint pass * comment formatting for RTD * add upgrade_downgrade_example in C++ * Add notes to environment variables markdown. * Improve error handling and text for env var errors - the OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL has checking to make sure the format is correct and that the version/label requested are present. - Adds a custom exception that gets raised if there is a problem - Adds a unit test for testing this behavior * Performance tuning (cache the child cloning encoder across the entire serialization, use const & as much as possible) Signed-off-by: ssteinbach <[email protected]> Co-authored-by: meshula <[email protected]> Signed-off-by: Michele Spina <[email protected]>
1 parent 98a671c commit ef70835

37 files changed

+2477
-304
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ htmlcov
1010
.vscode/
1111
xcuserdata/
1212
.venv/
13+
.cache
1314

1415
# Pycharm metadata
1516
.idea/

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ doc-plugins:
182182
doc-plugins-update:
183183
@python src/py-opentimelineio/opentimelineio/console/autogen_plugin_documentation.py -o docs/tutorials/otio-plugins.md --public-only --sanitized-paths
184184

185+
# build the CORE_VERSION_MAP cpp file
186+
version-map:
187+
@python src/py-opentimelineio/opentimelineio/console/autogen_version_map.py -i src/opentimelineio/CORE_VERSION_MAP.last.cpp --dryrun
188+
189+
version-map-update:
190+
@python src/py-opentimelineio/opentimelineio/console/autogen_version_map.py -i src/opentimelineio/CORE_VERSION_MAP.last.cpp -o src/opentimelineio/CORE_VERSION_MAP.cpp
191+
185192
# generate documentation in html
186193
doc-html:
187194
@# if you just want to build the docs yourself outside of RTD

docs/tutorials/otio-env-variables.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ various aspects of OTIO.
55

66
## Plugin Configuration
77

8-
These variables must be set _before_ the OpenTimelineIO python library is imported.
8+
These variables must be set _before_ the OpenTimelineIO python library is imported. They only impact the python library. The C++ library has no environment variables.
99

1010
- `OTIO_PLUGIN_MANIFEST_PATH`: a ":" separated string with paths to .manifest.json files that contain OTIO plugin manifests. See: [Tutorial on how to write an adapter plugin](write-an-adapter).
1111
- `OTIO_DEFAULT_MEDIA_LINKER`: the name of the default media linker to use after reading a file, if "" then no media linker is automatically invoked.
1212
- `OTIO_DISABLE_PKG_RESOURCE_PLUGINS`: By default, OTIO will use the pkg_resource entry_points mechanism to discover plugins that have been installed into the current python environment. pkg_resources, however, can be slow in certain cases, so for users who wish to disable this behavior, this variable can be set to 1.
13+
- `OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL`: if no downgrade arguments are passed to `write_to_file`/`write_to_string`, use the downgrade manifest specified by the family/label combination in the variable. Variable is of the form FAMILY:LABEL. Only one tuple of FAMILY:LABEL may be specified.
1314

1415
## Unit tests
1516

docs/tutorials/otio-plugins.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ OpenTimelineIO Final Cut Pro 7 XML Adapter.
106106
### otio_json
107107

108108
```
109-
This adapter lets you read and write native .otio files
109+
Adapter for reading and writing native .otio json files.
110110
```
111111

112112
*source*: `opentimelineio/adapters/otio_json.py`
@@ -147,14 +147,23 @@ Serializes an OpenTimelineIO object into a file
147147
indent (int): number of spaces for each json indentation level.
148148
Use -1 for no indentation or newlines.
149149
150+
If target_schema_versions is None and the environment variable
151+
"OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL" is set, will read a map out of
152+
that for downgrade target. The variable should be of the form
153+
FAMILY:LABEL, for example "MYSTUDIO:JUNE2022".
154+
150155
Returns:
151156
bool: Write success
152157
153158
Raises:
154159
ValueError: on write error
160+
otio.exceptions.InvalidEnvironmentVariableError: if there is a problem
161+
with the default environment variable
162+
"OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL".
155163
```
156164
- input_otio
157165
- filepath
166+
- target_schema_versions
158167
- indent
159168
- write_to_string:
160169
```
@@ -165,10 +174,21 @@ Serializes an OpenTimelineIO object into a string
165174
indent (int): number of spaces for each json indentation level. Use
166175
-1 for no indentation or newlines.
167176
177+
If target_schema_versions is None and the environment variable
178+
"OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL" is set, will read a map out of
179+
that for downgrade target. The variable should be of the form
180+
FAMILY:LABEL, for example "MYSTUDIO:JUNE2022".
181+
168182
Returns:
169183
str: A json serialized string representation
184+
185+
Raises:
186+
otio.exceptions.InvalidEnvironmentVariableError: if there is a problem
187+
with the default environment variable
188+
"OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL".
170189
```
171190
- input_otio
191+
- target_schema_versions
172192
- indent
173193

174194

docs/tutorials/otio-serialized-schema-only-fields.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ parameters:
121121
- *hooks*
122122
- *media_linkers*
123123
- *schemadefs*
124+
- *version_manifests*
124125

125126
### SerializableObject.1
126127

docs/tutorials/otio-serialized-schema.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ parameters:
254254
- *hooks*: Hooks that hooks scripts can be attached to.
255255
- *media_linkers*: Media Linkers this manifest describes.
256256
- *schemadefs*: Schemadefs this manifest describes.
257+
- *version_manifests*: Sets of versions to downgrade schemas to.
257258

258259
### SerializableObject.1
259260

0 commit comments

Comments
 (0)