|
| 1 | +# Schema Proposal and Development Workflow |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +This document describes a process for proposing and developing a new schema for the |
| 6 | +[OpenTimelineIO project](https://opentimeline.io). |
| 7 | + |
| 8 | +The process includes several steps: |
| 9 | + |
| 10 | +* Proposing at a TSC meeting and gathering interested parties for feedback |
| 11 | + * Outlining example JSON |
| 12 | +* Implementing and iterating on a branch |
| 13 | +* Building support into an adapter as a demonstration |
| 14 | +* Incrementing other schemas that are impacted (Eg. Changes to `Clip` to |
| 15 | + implement `Media Multi Reference` |
| 16 | + |
| 17 | +## Examples |
| 18 | + |
| 19 | +A number of schemas have been proposed and introduced during |
| 20 | +OpenTimelineIO's development. These include: |
| 21 | + |
| 22 | +* [ImageSequenceReference](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/pull/602) |
| 23 | +* [SpatialCoordinates](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/pull/1219) |
| 24 | +* [Multi media-reference](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/pull/1241) |
| 25 | + |
| 26 | +## Core schema or Plugin? |
| 27 | + |
| 28 | +OpenTimelineIO has a number of plugin mechanisms, including the |
| 29 | +[Schemadef](write-a-schemadef). Plugin schemadefs are great for things that |
| 30 | +aren't expected to be useful to the broader community, or are specific to a particular studio, |
| 31 | +workflow, or practice. Example of this might be a reference to a proprietary |
| 32 | +database or a proprietary effect. They can also be a good place to prototype a |
| 33 | +particular schema before proposing it to the community for adoption. |
| 34 | + |
| 35 | +## Proposal |
| 36 | + |
| 37 | +A proposal can be as fleshed out as a proposed implementation, or as vague as an |
| 38 | +idea. Presenting the proposal at a Technical Steering Committee for discussion |
| 39 | +is preferred so that interested parties can form a working group if necessary. |
| 40 | +The goal of a TSC presentation would be to find view points / impacts that might not have been considered |
| 41 | +and advertise the development to the community at large. |
| 42 | + |
| 43 | +Including an example JSON excerpt which has the fields you think might be needed |
| 44 | +can help. |
| 45 | + |
| 46 | +References that are particularly helpful are examples from existing |
| 47 | +applications/formats, information about how (or if) the schema participates in |
| 48 | +temporal transformations, and other relevant citations. |
| 49 | + |
| 50 | +## Implementing and Iterating on a branch |
| 51 | + |
| 52 | +Development of schemas typically takes longer and includes more feedback and |
| 53 | +review than normal development. To facilitate this, generally the project will |
| 54 | +open a branch on the repository so that pull requests can be merged into the |
| 55 | +prototype without disturbing the main branch. For example, the |
| 56 | +[ImageSequenceReference](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/pull/602) |
| 57 | +branch demonstrates that workflow. |
| 58 | + |
| 59 | +A complete implementation should have a: |
| 60 | + |
| 61 | +* C++ core implementation in src/opentimelineio |
| 62 | +* python binding in src/py-opentimelineio |
| 63 | +* unit tests |
| 64 | + |
| 65 | +### Unit Tests |
| 66 | + |
| 67 | +Unit Tests should include a C++ test for the C++ component, a python test for |
| 68 | +the python binding, and a baseline test. |
| 69 | + |
| 70 | +#### C++ test |
| 71 | + |
| 72 | +The C++ test should directly test the C++ interface. For examples of that, see |
| 73 | +`tests/*.cpp`. |
| 74 | + |
| 75 | +#### Python tests |
| 76 | + |
| 77 | +The Python test should test the python binding, including any extra ergonomic |
| 78 | +conveniences unique to the python implementation (iterators, etc). We use the |
| 79 | +`unittest` python library. For examples of this, see: `tests/test_*.py`. |
| 80 | + |
| 81 | +#### Baseline tests |
| 82 | + |
| 83 | +Baseline tests are written in python and are intended to test the serializer. |
| 84 | + |
| 85 | +They include: |
| 86 | + |
| 87 | +* a file named `tests/baselines/empty_<your_schema>.json`, which is the result |
| 88 | + of calling the constructor and then immediately serializing the object: |
| 89 | + |
| 90 | +```python |
| 91 | +ys = YourSchema() |
| 92 | +otio.adapters.write_to_file(ys, "empty_your_schema.json", adapter="otio_json") |
| 93 | +``` |
| 94 | + |
| 95 | +* a test in `tests/test_json_backend.py` of the form: |
| 96 | + |
| 97 | +```python |
| 98 | +class TestJsonFormat(unittest.TestCase, otio_test_utils.OTIOAssertions): |
| 99 | + ... |
| 100 | + def test_your_schema(self): |
| 101 | + ys = YourSchema() |
| 102 | + self.check_against_baseline(ys, "empty_your_schema") |
| 103 | + ... |
| 104 | +``` |
| 105 | + |
| 106 | +## Demo Adapter |
| 107 | + |
| 108 | +Providing an adapter that supports the schema can show how the schema is |
| 109 | +translated into another format. For example, the |
| 110 | +[ImageSequenceReference](https://github.com/AcademySoftwareFoundation/OpenTimelineIO/pull/722) |
| 111 | +used the RV adapter to demonstrate how it could be used by an adapter. |
| 112 | + |
| 113 | +## Incrementing Other Schemas |
| 114 | + |
| 115 | +Depending on where the schema fits into the overall structure, other schemas |
| 116 | +might need to be incremented or changed. For example, the Media |
| 117 | +multi-reference caused the clip schema to increment. Considering and |
| 118 | +implementing this is part of the implementation. Providing up and downgrade |
| 119 | +functions ensure backwards and forwards compatibility. |
| 120 | + |
| 121 | +## Conclusion |
| 122 | + |
| 123 | +OpenTimelineIO is designed to evolve, and through its schema versioning system |
| 124 | +hopes to adapt to changes in the world of timelines and time math. We hope |
| 125 | +that working with and on OpenTimelineIO can be a positive, enriching experience |
| 126 | +for the community. Thanks for being a part of it! |
0 commit comments