From 6df2b8ba939c4e0a7d50c05981f51faf1b3d0b2f Mon Sep 17 00:00:00 2001 From: Bobby Noelte Date: Thu, 30 Oct 2025 10:54:36 +0100 Subject: [PATCH] fix: generate config markdown Signed-off-by: Bobby Noelte --- openapi.json | 11 ++++++++--- scripts/generate_config_md.py | 9 ++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/openapi.json b/openapi.json index b0a7516..98cbb79 100644 --- a/openapi.json +++ b/openapi.json @@ -5803,9 +5803,13 @@ "title": "Total Costs Amt", "description": "The total costs [money amount]." }, - "data": { + "prediction": { "$ref": "#/components/schemas/PydanticDateTimeDataFrame", - "description": "Datetime data frame with time series optimization data per optimization interval:- load_energy_wh: Load of all energy consumers in wh- grid_energy_wh: Grid energy feed in (negative) or consumption (positive) in wh- pv_prediction_energy_wh: PV energy prediction (positive) in wh- elec_price_prediction_amt_kwh: Electricity price prediction in money per kwh- costs_amt: Costs in money amount- revenue_amt: Revenue in money amount- losses_energy_wh: Energy losses in wh- _operation_mode_id: Operation mode id of the device.- _operation_mode_factor: Operation mode factor of the device.- _soc_factor: State of charge of a battery/ electric vehicle device as factor of total capacity.- _energy_wh: Energy consumption (positive) of a device in wh." + "description": "Datetime data frame with time series prediction data per optimization interval:- pv_energy_wh: PV energy prediction (positive) in wh- elec_price_amt_kwh: Electricity price prediction in money per kwh- feed_in_tariff_amt_kwh: Feed in tariff prediction in money per kwh- weather_temp_air_celcius: Temperature in \u00b0C- load_mean_energy_wh: Load mean energy prediction in wh- load_std_energy_wh: Load energy standard deviation prediction in wh- load_mean_adjusted_energy_w: Adjusted load mean energy prediction in wh" + }, + "solution": { + "$ref": "#/components/schemas/PydanticDateTimeDataFrame", + "description": "Datetime data frame with time series solution data per optimization interval:- load_energy_wh: Load of all energy consumers in wh- grid_energy_wh: Grid energy feed in (negative) or consumption (positive) in wh- costs_amt: Costs in money amount- revenue_amt: Revenue in money amount- losses_energy_wh: Energy losses in wh- _operation_mode_id: Operation mode id of the device.- _operation_mode_factor: Operation mode factor of the device.- _soc_factor: State of charge of a battery/ electric vehicle device as factor of total capacity.- _energy_wh: Energy consumption (positive) of a device in wh." } }, "type": "object", @@ -5815,7 +5819,8 @@ "total_losses_energy_wh", "total_revenues_amt", "total_costs_amt", - "data" + "prediction", + "solution" ], "title": "OptimizationSolution", "description": "General Optimization Solution." diff --git a/scripts/generate_config_md.py b/scripts/generate_config_md.py index 8804f26..12ba815 100755 --- a/scripts/generate_config_md.py +++ b/scripts/generate_config_md.py @@ -8,7 +8,7 @@ import re import sys import textwrap from pathlib import Path -from typing import Any, Union +from typing import Any, Type, Union from loguru import logger from pydantic.fields import ComputedFieldInfo, FieldInfo @@ -199,7 +199,8 @@ def generate_config_table_md( description = deprecated table += f"| {field_name} {env_entry}| `{type_name}` | `{read_only}` | `{default_value}` | {description} |\n" - inner_types: dict[PydanticBaseModel, tuple[str, list[str]]] = dict() + # inner_types: dict[type[PydanticBaseModel], tuple[str, list[str]]] = dict() + inner_types: dict[Any, tuple[str, list[str]]] = dict() def extract_nested_models(subtype: Any, subprefix: str, parent_types: list[str]): """Extract nested models.""" @@ -207,7 +208,9 @@ def generate_config_table_md( return nested_types = resolve_nested_types(subtype, []) for nested_type, nested_parent_types in nested_types: - if issubclass(nested_type, PydanticBaseModel): + # Nested type may be of type class, enum, typing.Any + if isinstance(nested_type, type) and issubclass(nested_type, PydanticBaseModel): + # Nested type is a subclass of PydanticBaseModel new_parent_types = parent_types + nested_parent_types if "list" in parent_types: new_prefix = ""