nauta icon indicating copy to clipboard operation
nauta copied to clipboard

Upgrade to marshmallow 3

Open sloria opened this issue 6 years ago • 2 comments

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.

sloria avatar Feb 01 '19 04:02 sloria

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

AdamTumi avatar Feb 01 '19 12:02 AdamTumi

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. 😄

sloria avatar Aug 18 '19 23:08 sloria