openclimatefix / uk-pvnet-app

Application for running PVNet in production
MIT License
1 stars 5 forks source link

Pydantic model for config #96

Open peterdudfield opened 2 months ago

peterdudfield commented 2 months ago

Detailed Description

Our configuration is getting a bit more complicated. It might worth having a pydantic model, with some default values.

Context

Possible Implementation

rudra2112 commented 2 months ago

Hi @peterdudfield, I would like to pick this issue. Can you elaborate on what needs to be done, so that I can move in the right direction and get started.

peterdudfield commented 2 months ago

Hi @rudra2112 thanks for getting in touch

We currently have big dictionary that reapeats it self sometimes - here

I think we need to

  1. Create a pyandatic model. Perhsps the fields can be the same as the dictionary keys
  2. write yaml file with these variables in it
  3. load the yaml file in the main app.
  4. Have a different yaml file for the day ahead configuration https://github.com/openclimatefix/pvnet_app/blob/main/pvnet_app/app.py#L161

have you worked with pydantic before?

rudra2112 commented 2 months ago

@peterdudfield, Thanks for the reply, Will start working on it. And Yeah I have worked a bit with Pydantic Models before.

rudra2112 commented 2 months ago

Hey @peterdudfield, Should I replace with model_dict with a Pydantic Model with the fields pvnet_v2, pvnet_v2_sat0min_v9_batches, etc. and all its occurrences or just the the model config with pydantic model? And how should I structure the additions? the yamls, and models.py

peterdudfield commented 2 months ago

Yea I would do something like that. Perhaps models.py could contain a pydantic model called Model and it could have the following fields

you might need a second pydnatic model, call Models which is a list of model. You can then easily save the dict to yaml file and can be loaded easily.

Does this make sense?