Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to marshmallow 3 #40

Open
sloria opened this issue Aug 19, 2019 · 3 comments
Open

Upgrade to marshmallow 3 #40

sloria opened this issue Aug 19, 2019 · 3 comments

Comments

@sloria
Copy link

sloria commented Aug 19, 2019

馃憢 Just dropping by to let you know that marshmallow v3 is released.

Upgrading will provide a few benefits for boundary-layer:

before = fields.List(fields.Nested(OperatorSchema))
operators = fields.List(fields.Nested(OperatorSchema))
after = fields.List(fields.Nested(OperatorSchema))

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.

  1. Use data_key instead instead of load_from and dump_to.
  2. Change usages of .load and .dump to 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()
  1. Add **kwargs to 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/ ! 馃槃

@dossett
Copy link
Contributor

dossett commented Sep 5, 2019

Thanks @sloria, especially for the overview and migration tips! We hop to be taking the py3 plunge sometime soon. Cheers!

@aksswami
Copy link

Please check #57 , once merged it should resolve this issue.

@2timesjay
Copy link

Hah, this just came up for us because Langchain requires Marshmallow > 3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants