znicholls / CMIP6-json-data-citation-generator

Simple scripts to automatically generate json data citations for CMIP6 data files
https://cmip6-json-data-citation-generator.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
1 stars 2 forks source link

Restructuring #12

Closed znicholls closed 5 years ago

znicholls commented 6 years ago

To change:

from marshmallow import Schema, fields

class AssertSchema(Schema):
    variable = fields.String(required=True)
    expected = fields.Float(required=True)
    threshold = fields.Float()
    year = fields.Integer(default=2100)
    region = fields.String(default='GLOBAL')

class TestSchema(Schema):
    name = fields.String(required=True)
    start_year = fields.Integer(default=1750)
    end_year = fields.Integer(default=2100)
    asserts = fields.Nested(AssertSchema, many=True) 

class CollectionSchema(Schema):
    base_config = fields.String(required=True)
    tests = fields.Nested(TestSchema, many=True)

validated = CollectionSchema(strict=True).load(config)
znicholls commented 6 years ago

Full details in loading section of https://marshmallow.readthedocs.io/en/3.0/quickstart.html#deserializing-objects-loading

znicholls commented 5 years ago

done in various merge requests