ESM-VFC / esm-vfc-api-demo

MIT License
3 stars 2 forks source link

WIP: Experimenting with coverageJSON #11

Closed benbovy closed 3 years ago

benbovy commented 3 years ago

Closes #8.

I plan to add here a few API endpoints that return model data formatted as coverageJSON.

benbovy commented 3 years ago

I've just added some demo API endpoints to:

@willirath, @alirezamdv You'll be able to try it using the interactive /docs and copy/paste the results in https://covjson.org/playground/ to quickly visualize the extracted data.

I ended up implementing the coverageJSON specs as pydantic models. It's still not complete but ~ 80% of the specs are already implemented. I followed the specs quite strictly. This results in a lot of small pydantic models and right now looks a bit verbose compared to using plain Python dictionaries. However, we really benefit from pydantic's automated validation and I'm sure that a few helper functions for converting xarray Datasets from/to pydantic model instances will allow us to write new API endpoints super efficiently.

We could still further polish things like endpoint path names and input parameters, but this can be done later as this is still experimental. To me it's ready to merge, so that @alirezamdv can give it a try.