NVE / varsomdata

Repository contains methods and modules for accessing api's for regObs, The forecasting-api and The chart server which provides charts to seNorge and xGeo. All these products are a part of the Varsom-family; products used in forecasting at NVE.
MIT License
2 stars 1 forks source link

Use autogenerated python apis for regobs, warning apis, etc #6

Open jorgkv opened 3 years ago

jorgkv commented 3 years ago

I did an experiment some time ago to auto-generate python apis using swagger:

They can be generated using asyncio or without. We should consider using these in varsomdata. I am not sure if it is a good idea or not, but we should discuss it here.

jorgkv commented 3 years ago

If we think it is a good idea to use the auto-generated packages, they should be updated before we start using them.

widforss commented 3 years ago

Those python libraries will still basically return JSONs for single days, right? So while it might be a good idea, it won't allow us to remove any code från varsomdata, except some HTTP requests.

Or have I misunderstood what those libraries do?

jorgkv commented 3 years ago

If you look at getobservations.py most of the classes there are just mapping returned json data to python classes.

Compare this class: https://github.com/NVE/varsomdata/blob/5c7b750998da1f72319529d22b2e8c0e76511ad7/varsomdata/getobservations.py#L1145

To this autogenerated class: https://github.com/NVE/python-varsom-regobs-client/blob/8bb7fc06d2f6da36a5fa4a475d4f036ebe3cfd72/varsom_regobs_client/models/avalanche_activity_obs_dto.py#L19

and you can see the autogenerated code is pretty similar.

By using the autogenerated code we could probably remove most of the code from getobservations.py, and we have similar autogenerated apis and models for forecast apis as well.

jorgkv commented 3 years ago

We would have less control over how the mapping is done, so I am not saying it's the best solution, but we could probably remove a lot of code I think, and changes in the API would be easy to implement, mostly just autogenerating the api/models code again.