openclimatefix / nowcasting_datamodel

Datamodel for the nowcasting project
6 stars 6 forks source link

Create ForecastValueYearMonth with factory function to avoid warning message #276

Closed dfulu closed 7 months ago

dfulu commented 7 months ago

The way the ForecastValueYearMonth classes are created for each year and month currently causes a warning message when this library is imported like:

warnings.warn(message, UserWarning)
.../nowcasting_datamodel/models/forecast.py:212: SAWarning: This declarative base already contains a class 
with the same class name and module name as nowcasting_datamodel.models.forecast.ForecastValueYearMonth, 
and will be replaced in the string-lookup table.

This pull request creates the classes dynamically and should remove the warning message since the class names are distinct for each year and month

Closes #148

Checklist:

peterdudfield commented 7 months ago

Ive run migrations locally, and as expected

  1. no new migrations casued by this code
  2. new forecast_value_YYYY_MM tables can be created as usual