Skip to content

Commit c1df163

Browse files
committed
properly link ForecasterParametersSchema in OpenAPI specs
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
1 parent fa098f9 commit c1df163

File tree

2 files changed

+169
-33
lines changed

2 files changed

+169
-33
lines changed

flexmeasures/api/v3_0/sensors.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,21 +1522,7 @@ def trigger_forecast(self, id: int, **params):
15221522
required: true
15231523
content:
15241524
application/json:
1525-
schema:
1526-
type: object
1527-
properties:
1528-
start_date:
1529-
type: string
1530-
format: date-time
1531-
description: Start date of the historical data used for training.
1532-
start_predict_date:
1533-
type: string
1534-
format: date-time
1535-
description: Start date of the forecast period.
1536-
end_date:
1537-
type: string
1538-
format: date-time
1539-
description: End date of the forecast period.
1525+
schema: ForecasterParametersSchema
15401526
example:
15411527
start_date: "2026-01-01T00:00:00+01:00"
15421528
start_predict_date: "2026-01-15T00:00:00+01:00"

flexmeasures/ui/static/openapi-specs.json

Lines changed: 168 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,24 +1186,7 @@
11861186
"content": {
11871187
"application/json": {
11881188
"schema": {
1189-
"type": "object",
1190-
"properties": {
1191-
"start_date": {
1192-
"type": "string",
1193-
"format": "date-time",
1194-
"description": "Start date of the historical data used for training."
1195-
},
1196-
"start_predict_date": {
1197-
"type": "string",
1198-
"format": "date-time",
1199-
"description": "Start date of the forecast period."
1200-
},
1201-
"end_date": {
1202-
"type": "string",
1203-
"format": "date-time",
1204-
"description": "End date of the forecast period."
1205-
}
1206-
}
1189+
"$ref": "#/components/schemas/ForecasterParameters"
12071190
},
12081191
"example": {
12091192
"start_date": "2026-01-01T00:00:00+01:00",
@@ -5106,6 +5089,173 @@
51065089
],
51075090
"additionalProperties": false
51085091
},
5092+
"ForecasterParameters": {
5093+
"type": "object",
5094+
"properties": {
5095+
"sensor": {
5096+
"type": "integer",
5097+
"description": "ID of the sensor to forecast.",
5098+
"example": 2092
5099+
},
5100+
"future_regressors": {
5101+
"type": "array",
5102+
"description": "Sensor IDs to be treated only as future regressors.",
5103+
"example": [
5104+
2093,
5105+
2094
5106+
],
5107+
"items": {
5108+
"type": "integer"
5109+
}
5110+
},
5111+
"past_regressors": {
5112+
"type": "array",
5113+
"description": "Sensor IDs to be treated only as past regressors.",
5114+
"example": [
5115+
2095
5116+
],
5117+
"items": {
5118+
"type": "integer"
5119+
}
5120+
},
5121+
"regressors": {
5122+
"type": "array",
5123+
"description": "Sensor IDs used as both past and future regressors.",
5124+
"example": [
5125+
2093,
5126+
2094,
5127+
2095
5128+
],
5129+
"items": {
5130+
"type": "integer"
5131+
}
5132+
},
5133+
"model_save_dir": {
5134+
"type": [
5135+
"string",
5136+
"null"
5137+
],
5138+
"default": "flexmeasures/data/models/forecasting/artifacts/models",
5139+
"description": "Directory to save the trained model.",
5140+
"example": "flexmeasures/data/models/forecasting/artifacts/models"
5141+
},
5142+
"output_path": {
5143+
"type": [
5144+
"string",
5145+
"null"
5146+
],
5147+
"description": "Directory to save prediction outputs. Defaults to None (no outputs saved).",
5148+
"example": "flexmeasures/data/models/forecasting/artifacts/forecasts"
5149+
},
5150+
"start_date": {
5151+
"type": [
5152+
"string",
5153+
"null"
5154+
],
5155+
"format": "date-time",
5156+
"description": "Timestamp marking the start of training data. Defaults to train_period before start_predict_date if not set.",
5157+
"example": "2025-01-01T00:00:00+01:00"
5158+
},
5159+
"end_date": {
5160+
"type": [
5161+
"string",
5162+
"null"
5163+
],
5164+
"format": "date-time",
5165+
"description": "End date for running the pipeline.",
5166+
"example": "2025-10-15T00:00:00+01:00"
5167+
},
5168+
"train_period": {
5169+
"type": [
5170+
"string",
5171+
"null"
5172+
],
5173+
"description": "Duration of the initial training period (ISO 8601 format, min 2 days). If not set, derived from start_date and start_predict_date or defaults to P30D (30 days).",
5174+
"example": "P7D"
5175+
},
5176+
"start_predict_date": {
5177+
"type": [
5178+
"string",
5179+
"null"
5180+
],
5181+
"format": "date-time",
5182+
"description": "Start date for predictions. Defaults to now, floored to the sensor resolution, so that the first forecast is about the ongoing event.",
5183+
"example": "2025-01-08T00:00:00+01:00"
5184+
},
5185+
"retrain_frequency": {
5186+
"type": [
5187+
"string",
5188+
"null"
5189+
],
5190+
"description": "Frequency of retraining/prediction cycle (ISO 8601 duration). Defaults to prediction window length if not set.",
5191+
"example": "PT24H"
5192+
},
5193+
"max_forecast_horizon": {
5194+
"type": [
5195+
"string",
5196+
"null"
5197+
],
5198+
"default": "P2D",
5199+
"description": "Maximum forecast horizon. Defaults to 48 hours if not set.",
5200+
"example": "PT48H"
5201+
},
5202+
"forecast_frequency": {
5203+
"type": [
5204+
"string",
5205+
"null"
5206+
],
5207+
"default": "PT1H",
5208+
"description": "How often to recompute forecasts. Defaults to 1 hour.",
5209+
"example": "PT1H"
5210+
},
5211+
"probabilistic": {
5212+
"type": "boolean",
5213+
"default": false,
5214+
"description": "Enable probabilistic predictions if True. Defaults to false.",
5215+
"example": false
5216+
},
5217+
"sensor_to_save": {
5218+
"type": [
5219+
"integer",
5220+
"null"
5221+
],
5222+
"description": "Sensor ID where forecasts will be saved; defaults to target sensor.",
5223+
"example": 2092
5224+
},
5225+
"ensure_positive": {
5226+
"type": [
5227+
"boolean",
5228+
"null"
5229+
],
5230+
"description": "Whether to clip negative values in forecasts. Defaults to None (disabled).",
5231+
"example": true
5232+
},
5233+
"missing_threshold": {
5234+
"type": "number",
5235+
"default": 1.0,
5236+
"description": "Maximum fraction of missing data allowed before raising an error. Defaults to 1.0.",
5237+
"example": 0.1
5238+
},
5239+
"as_job": {
5240+
"type": "boolean",
5241+
"default": false,
5242+
"description": "If True, compute forecasts asynchronously using RQ jobs. Defaults to False.",
5243+
"example": true
5244+
},
5245+
"max_training_period": {
5246+
"type": [
5247+
"string",
5248+
"null"
5249+
],
5250+
"description": "Maximum duration of the training period. Defaults to 1 year (P1Y).",
5251+
"example": "P1Y"
5252+
}
5253+
},
5254+
"required": [
5255+
"sensor"
5256+
],
5257+
"additionalProperties": false
5258+
},
51095259
"TriggerScheduleKwargs": {
51105260
"type": "object",
51115261
"properties": {

0 commit comments

Comments
 (0)