Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Upgrade to marshmallow 3 #2

Open
sloria opened this issue Feb 1, 2019 · 2 comments
Open

Upgrade to marshmallow 3 #2

sloria opened this issue Feb 1, 2019 · 2 comments

Comments

@sloria
Copy link

sloria commented Feb 1, 2019

marshmallow 3.0.0rc2 is out, and a stable release is just around the corner. We don't expect any more large breaking changes, so we are recommending that new projects use marshmallow 3.

One benefit of upgrading is that you will be able to get rid of the duplicate load_from/dump_to arguments, like here:

https://github.com/IntelAI/nauta/blob/afcf19d236d25bb6157eb67b26b0984d47ff142c/applications/cli/platform_resources/custom_object_meta_model.py#L36-L39

In marshmallow 3, these parameters have been merged into a single parameter, data_key.

cluster_name = fields.String(required=False, allow_none=True, missing=None, data_key='clusterName')

There are other marshmallow 3 features that Nauta could take advantage, of, like structured Dict fields:

    labels = fields.Dict(keys=fields.Str(), values=fields.Str(), required=False, allow_none=True, missing=None)

The migration should be relatively straightforward. In addition to using data_key instead of load_from/dump_to, it looks like you'll need to adjust usages like this...

https://github.com/IntelAI/nauta/blob/a65a6a573f410ca19941abdfa9c33dfcea8f3ed4/applications/cli/platform_resources/run.py#L173-L175

to marshmallow 3's more strict (and more simple) API:

try:
    created_run = schema.load(response)
except ValidationError as err:
    raise RuntimeError(f'load of RunKubernetes request object error - {err.messages}')

EDIT: Update data_key example.

@AdamTumi
Copy link
Contributor

AdamTumi commented Feb 1, 2019

@sloria - thanks for a heads-up. We'll consider moving to marshmallow 3 in Nauta's future releases.

@sloria
Copy link
Author

sloria commented Aug 18, 2019

FYI: marshmallow v3 (stable) has been released. Along with the aforementioned API improvements, serialization performance is significantly better than v2. There's an upgrading guide here: https://marshmallow.readthedocs.io/en/stable/upgrading.html . Please don't hesitate to ask questions or report issues on the marshmallow issue tracker. 😄

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

No branches or pull requests

2 participants