-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
👋 Just dropping by to let you know that marshmallow v3 is released.
Upgrading will provide a few benefits for boundary-layer:
- No need for
StrictSchema. v3 has first-class support for unknown field validation, and the default behavior matchesStrictSchema: https://marshmallow.readthedocs.io/en/stable/quickstart.html#handling-unknown-fields List(Nested(...))has been improved to have the same validation and performance characteristics asNested(many=True)(List(Nested) was previously slower due toNested(many=True)taking an optimized path)
boundary-layer/boundary_layer/schemas/dag.py
Lines 87 to 89 in 9b09956
| before = fields.List(fields.Nested(OperatorSchema)) | |
| operators = fields.List(fields.Nested(OperatorSchema)) | |
| after = fields.List(fields.Nested(OperatorSchema)) |
- You can get rid of places where
load_fromanddump_tomatch, since they've been merged into a single parameter,data_key.
boundary-layer/boundary_layer_default_plugin/oozie_actions.py
Lines 86 to 87 in 5e52e1c
| load_from='property', | |
| dump_to='property', |
- Serialization performance is significantly improved compared to v2
I've only skimmed the boundary-layer code, but it looks like the migration should be relatively straightforward.
- Use
data_keyinstead instead ofload_fromanddump_to. - Change usages of
.loadand.dumpto handle ValidationError and expect the (de)serialized data dictionary to be returned.
try:
data = OozieWorkflowSchema(context={
'cluster_config': cluster_config,
'oozie_plugin': oozie_config,
'macro_translator': JspMacroTranslator(oozie_config.jsp_macros()),
'production': self.production,
}).load(parsed)
except ma.ValidationError:
raise Exception('Errors parsing file {}: {}'.format(
filename,
loaded.errors))
data_copy = data.copy()- Add
**kwargsto decorated methods.
@validates_schema
def validate_template_undefined(self, data, **kwargs):
# ...
@post_dump
def dagrun_timeout_to_timedelta(self, data, **kwargs):
# ...A full upgrading guide is here: https://marshmallow.readthedocs.io/en/latest/upgrading.html
It's worth knowing that marshmallow 3 only supports Python 3. So you'd need to drop support for 2.7 in order to upgrade. Join the party https://python3statement.org/ ! 😄
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels