Skip to content

Commit e1f3791

Browse files
authored
Updated Effect schema with enabled flag (#1798)
* Adds enabled flag to Effect - Updated Effect schema to version 2 and core version to 0.18.0 - Updated unit tests to account for enabled flag * Fixed blank lines linting errors * Reverted version bump for schema and core --------- Signed-off-by: Florian Schleich <fschleich@netflix.com>
1 parent 6d733fd commit e1f3791

File tree

9 files changed

+60
-12
lines changed

9 files changed

+60
-12
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ parameters:
144144

145145
parameters:
146146
- *effect_name*
147+
- *enabled*
147148
- *metadata*
148149
- *name*
149150

@@ -160,6 +161,7 @@ parameters:
160161

161162
parameters:
162163
- *effect_name*
164+
- *enabled*
163165
- *metadata*
164166
- *name*
165167
- *time_scalar*
@@ -204,6 +206,7 @@ parameters:
204206

205207
parameters:
206208
- *effect_name*
209+
- *enabled*
207210
- *metadata*
208211
- *name*
209212
- *time_scalar*
@@ -245,6 +248,7 @@ parameters:
245248

246249
parameters:
247250
- *effect_name*
251+
- *enabled*
248252
- *metadata*
249253
- *name*
250254

docs/tutorials/otio-serialized-schema.md

+4
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ None
310310

311311
parameters:
312312
- *effect_name*:
313+
- *enabled*: If true, the Effect is applied. If false, the Effect is omitted.
313314
- *metadata*:
314315
- *name*:
315316

@@ -342,6 +343,7 @@ Hold the first frame of the clip for the duration of the clip.
342343

343344
parameters:
344345
- *effect_name*:
346+
- *enabled*: If true, the Effect is applied. If false, the Effect is omitted.
345347
- *metadata*:
346348
- *name*:
347349
- *time_scalar*: Linear time scalar applied to clip. 2.0 means the clip occupies half the time in the parent item, i.e. plays at double speed,
@@ -500,6 +502,7 @@ A time warp that applies a linear speed up or slow down across the entire clip.
500502

501503
parameters:
502504
- *effect_name*:
505+
- *enabled*: If true, the Effect is applied. If false, the Effect is omitted.
503506
- *metadata*:
504507
- *name*:
505508
- *time_scalar*: Linear time scalar applied to clip. 2.0 means the clip occupies half the time in the parent item, i.e. plays at double speed,
@@ -607,6 +610,7 @@ Base class for all effects that alter the timing of an item.
607610

608611
parameters:
609612
- *effect_name*:
613+
- *enabled*: If true, the Effect is applied. If false, the Effect is omitted.
610614
- *metadata*:
611615
- *name*:
612616

src/opentimelineio/effect.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
99
Effect::Effect(
1010
std::string const& name,
1111
std::string const& effect_name,
12-
AnyDictionary const& metadata)
12+
AnyDictionary const& metadata,
13+
bool enabled)
1314
: Parent(name, metadata)
1415
, _effect_name(effect_name)
16+
, _enabled(enabled)
1517
{}
1618

1719
Effect::~Effect()
@@ -21,6 +23,7 @@ bool
2123
Effect::read_from(Reader& reader)
2224
{
2325
return reader.read("effect_name", &_effect_name)
26+
&& reader.read_if_present("enabled", &_enabled)
2427
&& Parent::read_from(reader);
2528
}
2629

@@ -29,6 +32,7 @@ Effect::write_to(Writer& writer) const
2932
{
3033
Parent::write_to(writer);
3134
writer.write("effect_name", _effect_name);
35+
writer.write("enabled", _enabled);
3236
}
3337

3438
}} // namespace opentimelineio::OPENTIMELINEIO_VERSION

src/opentimelineio/effect.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Effect : public SerializableObjectWithMetadata
2222
Effect(
2323
std::string const& name = std::string(),
2424
std::string const& effect_name = std::string(),
25-
AnyDictionary const& metadata = AnyDictionary());
25+
AnyDictionary const& metadata = AnyDictionary(),
26+
bool enabled = true);
2627

2728
std::string effect_name() const noexcept { return _effect_name; }
2829

@@ -31,6 +32,10 @@ class Effect : public SerializableObjectWithMetadata
3132
_effect_name = effect_name;
3233
}
3334

35+
bool enabled() const { return _enabled; };
36+
37+
void set_enabled(bool enabled) { _enabled = enabled; }
38+
3439
protected:
3540
virtual ~Effect();
3641

@@ -39,6 +44,7 @@ class Effect : public SerializableObjectWithMetadata
3944

4045
private:
4146
std::string _effect_name;
47+
bool _enabled;
4248
};
4349

4450
}} // namespace opentimelineio::OPENTIMELINEIO_VERSION

src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,15 @@ static void define_effects(py::module m) {
657657
py::class_<Effect, SOWithMetadata, managing_ptr<Effect>>(m, "Effect", py::dynamic_attr())
658658
.def(py::init([](std::string name,
659659
std::string effect_name,
660-
py::object metadata) {
661-
return new Effect(name, effect_name, py_to_any_dictionary(metadata)); }),
660+
py::object metadata,
661+
py::bool_ enabled) {
662+
return new Effect(name, effect_name, py_to_any_dictionary(metadata), enabled); }),
662663
py::arg_v("name"_a = std::string()),
663664
"effect_name"_a = std::string(),
664-
py::arg_v("metadata"_a = py::none()))
665-
.def_property("effect_name", &Effect::effect_name, &Effect::set_effect_name);
665+
py::arg_v("metadata"_a = py::none()),
666+
"enabled"_a = true)
667+
.def_property("effect_name", &Effect::effect_name, &Effect::set_effect_name)
668+
.def_property("enabled", &Effect::enabled, &Effect::set_enabled, "If true, the Effect is applied. If false, the Effect is omitted.");
666669

667670
py::class_<TimeEffect, Effect, managing_ptr<TimeEffect>>(m, "TimeEffect", py::dynamic_attr(), "Base class for all effects that alter the timing of an item.")
668671
.def(py::init([](std::string name,

src/py-opentimelineio/opentimelineio/schema/effect.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ def __str__(self):
1111
"Effect("
1212
"{}, "
1313
"{}, "
14+
"{}, "
1415
"{}"
1516
")".format(
1617
str(self.name),
1718
str(self.effect_name),
1819
str(self.metadata),
20+
str(self.enabled)
1921
)
2022
)
2123

@@ -26,10 +28,12 @@ def __repr__(self):
2628
"otio.schema.Effect("
2729
"name={}, "
2830
"effect_name={}, "
29-
"metadata={}"
31+
"metadata={}, "
32+
"enabled={}"
3033
")".format(
3134
repr(self.name),
3235
repr(self.effect_name),
3336
repr(self.metadata),
37+
repr(self.enabled)
3438
)
3539
)

tests/baselines/empty_effect.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"OTIO_SCHEMA" : "Effect.1",
3+
"name" : "",
4+
"effect_name" : "",
5+
"metadata" : {},
6+
"enabled" : true
7+
}

tests/test_effect.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ def test_cons(self):
1313
ef = otio.schema.Effect(
1414
name="blur it",
1515
effect_name="blur",
16-
metadata={"foo": "bar"}
16+
metadata={"foo": "bar"},
17+
enabled=False
1718
)
19+
20+
self.assertEqual(ef.enabled, False)
21+
1822
encoded = otio.adapters.otio_json.write_to_string(ef)
1923
decoded = otio.adapters.otio_json.read_from_string(encoded)
2024
self.assertIsOTIOEquivalentTo(ef, decoded)
2125
self.assertEqual(decoded.name, "blur it")
2226
self.assertEqual(decoded.effect_name, "blur")
2327
self.assertEqual(decoded.metadata['foo'], 'bar')
28+
self.assertEqual(decoded.enabled, False)
2429

2530
def test_eq(self):
2631
ef = otio.schema.Effect(
@@ -39,26 +44,30 @@ def test_str(self):
3944
ef = otio.schema.Effect(
4045
name="blur it",
4146
effect_name="blur",
42-
metadata={"foo": "bar"}
47+
metadata={"foo": "bar"},
48+
enabled=False
4349
)
4450
self.assertMultiLineEqual(
4551
str(ef),
46-
"Effect({}, {}, {})".format(
52+
"Effect({}, {}, {}, {})".format(
4753
str(ef.name),
4854
str(ef.effect_name),
49-
str(ef.metadata)
55+
str(ef.metadata),
56+
str(ef.enabled)
5057
)
5158
)
5259
self.assertMultiLineEqual(
5360
repr(ef),
5461
"otio.schema.Effect("
5562
"name={}, "
5663
"effect_name={}, "
57-
"metadata={}"
64+
"metadata={}, "
65+
"enabled={}"
5866
")".format(
5967
repr(ef.name),
6068
repr(ef.effect_name),
6169
repr(ef.metadata),
70+
repr(ef.enabled)
6271
)
6372
)
6473

@@ -71,6 +80,7 @@ def test_setters(self):
7180
self.assertEqual(ef.effect_name, "blur")
7281
ef.effect_name = "flop"
7382
self.assertEqual(ef.effect_name, "flop")
83+
self.assertEqual(ef.enabled, True)
7484

7585

7686
class TestLinearTimeWarp(unittest.TestCase, otio_test_utils.OTIOAssertions):
@@ -80,6 +90,7 @@ def test_cons(self):
8090
self.assertEqual(ef.name, "Foo")
8191
self.assertEqual(ef.time_scalar, 2.5)
8292
self.assertEqual(ef.metadata, {"foo": "bar"})
93+
self.assertEqual(ef.enabled, True)
8394

8495
def test_serialize(self):
8596
ef = otio.schema.LinearTimeWarp("Foo", 2.5, {'foo': 'bar'})
@@ -101,6 +112,7 @@ def test_cons(self):
101112
self.assertEqual(ef.name, "Foo")
102113
self.assertEqual(ef.time_scalar, 0)
103114
self.assertEqual(ef.metadata, {"foo": "bar"})
115+
self.assertEqual(ef.enabled, True)
104116

105117

106118
if __name__ == '__main__':

tests/test_json_backend.py

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ def test_marker(self):
104104
mr = otio.schema.Marker()
105105
self.check_against_baseline(mr, "empty_marker")
106106

107+
def test_effect(self):
108+
mr = otio.schema.Effect()
109+
self.check_against_baseline(mr, "empty_effect")
110+
107111
def test_transition(self):
108112
trx = otio.schema.Transition()
109113
self.check_against_baseline(trx, "empty_transition")

0 commit comments

Comments
 (0)