From 54273a0c2176ed461c2bb8515d561262e5c7bf65 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Thu, 14 Sep 2023 18:53:32 +0200 Subject: [PATCH] run datamodel-codegen again --- docs/schema/Config.schema.json | 8 +++++ .../DiscreteControlCondition.schema.json | 4 +-- docs/schema/FlowBoundaryStatic.schema.json | 4 +-- docs/schema/LevelBoundaryStatic.schema.json | 4 +-- .../schema/LinearResistanceStatic.schema.json | 4 +-- .../ManningResistanceStatic.schema.json | 4 +-- docs/schema/OutletStatic.schema.json | 16 ++++----- docs/schema/PIDControlStatic.schema.json | 4 +-- docs/schema/PumpStatic.schema.json | 12 +++---- .../TabulatedRatingCurveStatic.schema.json | 4 +-- docs/schema/UserStatic.schema.json | 29 ++++++++------- docs/schema/UserTime.schema.json | 20 ++++------- docs/schema/user.schema.json | 35 +++++++++++++++++++ python/ribasim/ribasim/config.py | 8 +++++ python/ribasim/ribasim/models.py | 34 +++++++++--------- 15 files changed, 117 insertions(+), 73 deletions(-) create mode 100644 docs/schema/user.schema.json diff --git a/docs/schema/Config.schema.json b/docs/schema/Config.schema.json index f324fc81b..2125ba6da 100644 --- a/docs/schema/Config.schema.json +++ b/docs/schema/Config.schema.json @@ -38,6 +38,13 @@ }, "$ref": "https://deltares.github.io/Ribasim/schema/level_boundary.schema.json" }, + "user": { + "default": { + "static": null, + "time": null + }, + "$ref": "https://deltares.github.io/Ribasim/schema/user.schema.json" + }, "pump": { "default": { "static": null @@ -165,6 +172,7 @@ "level_boundary", "pump", "tabulated_rating_curve", + "user", "flow_boundary", "basin", "manning_resistance", diff --git a/docs/schema/DiscreteControlCondition.schema.json b/docs/schema/DiscreteControlCondition.schema.json index 3ce188fe2..00cd84ec3 100644 --- a/docs/schema/DiscreteControlCondition.schema.json +++ b/docs/schema/DiscreteControlCondition.schema.json @@ -27,10 +27,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] } diff --git a/docs/schema/FlowBoundaryStatic.schema.json b/docs/schema/FlowBoundaryStatic.schema.json index 8300ea9fd..429fe8f20 100644 --- a/docs/schema/FlowBoundaryStatic.schema.json +++ b/docs/schema/FlowBoundaryStatic.schema.json @@ -11,10 +11,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/LevelBoundaryStatic.schema.json b/docs/schema/LevelBoundaryStatic.schema.json index f635afce0..85ff75b67 100644 --- a/docs/schema/LevelBoundaryStatic.schema.json +++ b/docs/schema/LevelBoundaryStatic.schema.json @@ -11,10 +11,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/LinearResistanceStatic.schema.json b/docs/schema/LinearResistanceStatic.schema.json index 5a5146ea9..c0261ad6f 100644 --- a/docs/schema/LinearResistanceStatic.schema.json +++ b/docs/schema/LinearResistanceStatic.schema.json @@ -11,10 +11,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/ManningResistanceStatic.schema.json b/docs/schema/ManningResistanceStatic.schema.json index 22bad56df..f8ec17058 100644 --- a/docs/schema/ManningResistanceStatic.schema.json +++ b/docs/schema/ManningResistanceStatic.schema.json @@ -19,10 +19,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/OutletStatic.schema.json b/docs/schema/OutletStatic.schema.json index d8feae988..8c24fac8c 100644 --- a/docs/schema/OutletStatic.schema.json +++ b/docs/schema/OutletStatic.schema.json @@ -5,10 +5,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] }, @@ -22,10 +22,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, @@ -33,10 +33,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] }, @@ -63,10 +63,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] } diff --git a/docs/schema/PIDControlStatic.schema.json b/docs/schema/PIDControlStatic.schema.json index df64576ee..c3226017b 100644 --- a/docs/schema/PIDControlStatic.schema.json +++ b/docs/schema/PIDControlStatic.schema.json @@ -19,10 +19,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/PumpStatic.schema.json b/docs/schema/PumpStatic.schema.json index afe80e42c..fa15283fa 100644 --- a/docs/schema/PumpStatic.schema.json +++ b/docs/schema/PumpStatic.schema.json @@ -5,10 +5,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] }, @@ -22,10 +22,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, @@ -52,10 +52,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "number" }, { - "type": "number" + "type": "null" } ] } diff --git a/docs/schema/TabulatedRatingCurveStatic.schema.json b/docs/schema/TabulatedRatingCurveStatic.schema.json index cb244575b..c073e11c1 100644 --- a/docs/schema/TabulatedRatingCurveStatic.schema.json +++ b/docs/schema/TabulatedRatingCurveStatic.schema.json @@ -11,10 +11,10 @@ "format": "default", "anyOf": [ { - "type": "null" + "type": "boolean" }, { - "type": "boolean" + "type": "null" } ] }, diff --git a/docs/schema/UserStatic.schema.json b/docs/schema/UserStatic.schema.json index 4733934ca..e3e69755f 100644 --- a/docs/schema/UserStatic.schema.json +++ b/docs/schema/UserStatic.schema.json @@ -9,42 +9,41 @@ }, "priority": { "format": "default", - "description": "priority", "type": "integer" }, "active": { "format": "default", - "description": "active", - "type": [ - "string" + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } ] }, "demand": { "format": "double", - "description": "demand", "type": "number" }, "return_factor": { - "format": "default", - "description": "return_factor", - "type": "list" + "format": "double", + "type": "number" + }, + "min_level": { + "format": "double", + "type": "number" }, "node_id": { "format": "default", - "description": "node_id", "type": "integer" - }, - "allocated": { - "format": "double", - "description": "allocated", - "type": "number" } }, "required": [ "node_id", "demand", - "allocated", "return_factor", + "min_level", "priority" ], "$id": "https://deltares.github.io/Ribasim/schema/UserStatic.schema.json", diff --git a/docs/schema/UserTime.schema.json b/docs/schema/UserTime.schema.json index aa9eb10be..0b930a790 100644 --- a/docs/schema/UserTime.schema.json +++ b/docs/schema/UserTime.schema.json @@ -9,41 +9,35 @@ }, "priority": { "format": "default", - "description": "priority", "type": "integer" }, "time": { "format": "date-time", - "description": "time", "type": "string" }, "demand": { "format": "double", - "description": "demand", "type": "number" }, "return_factor": { - "format": "default", - "description": "return_factor", - "type": "list" + "format": "double", + "type": "number" + }, + "min_level": { + "format": "double", + "type": "number" }, "node_id": { "format": "default", - "description": "node_id", "type": "integer" - }, - "allocated": { - "format": "double", - "description": "allocated", - "type": "number" } }, "required": [ "node_id", "time", "demand", - "allocated", "return_factor", + "min_level", "priority" ], "$id": "https://deltares.github.io/Ribasim/schema/UserTime.schema.json", diff --git a/docs/schema/user.schema.json b/docs/schema/user.schema.json new file mode 100644 index 000000000..6fcacadf3 --- /dev/null +++ b/docs/schema/user.schema.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "time": { + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ], + "default": null + }, + "static": { + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + } + ], + "default": null + } + }, + "required": [ + ], + "$id": "https://deltares.github.io/Ribasim/schema/user.schema.json", + "title": "user", + "description": "A user object based on Ribasim.config.user", + "type": "object" +} diff --git a/python/ribasim/ribasim/config.py b/python/ribasim/ribasim/config.py index 1f5bc7662..096dcbc75 100644 --- a/python/ribasim/ribasim/config.py +++ b/python/ribasim/ribasim/config.py @@ -23,6 +23,11 @@ class LevelBoundary(BaseModel): static: Optional[str] = None +class User(BaseModel): + time: Optional[str] = None + static: Optional[str] = None + + class Pump(BaseModel): static: Optional[str] = None @@ -111,6 +116,9 @@ class Config(BaseModel): level_boundary: LevelBoundary = Field( default_factory=lambda: LevelBoundary.parse_obj({"static": None, "time": None}) ) + user: User = Field( + default_factory=lambda: User.parse_obj({"static": None, "time": None}) + ) pump: Pump = Field(default_factory=lambda: Pump.parse_obj({"static": None})) discrete_control: DiscreteControl = Field( default_factory=lambda: DiscreteControl.parse_obj( diff --git a/python/ribasim/ribasim/models.py b/python/ribasim/ribasim/models.py index e4ca81f28..f541fe4c4 100644 --- a/python/ribasim/ribasim/models.py +++ b/python/ribasim/ribasim/models.py @@ -4,7 +4,7 @@ from __future__ import annotations from datetime import datetime -from typing import Any, Optional +from typing import Optional from pydantic import BaseModel, Field @@ -32,13 +32,13 @@ class FlowBoundaryTime(BaseModel): class UserStatic(BaseModel): - remarks: Optional[str] = Field("", description="a hack for pandera") - priority: int = Field(..., description="priority") - active: Optional[str] = Field(None, description="active") - demand: float = Field(..., description="demand") - return_factor: Any = Field(..., description="return_factor") - node_id: int = Field(..., description="node_id") - allocated: float = Field(..., description="allocated") + remarks: str = Field("", description="a hack for pandera") + priority: int + active: Optional[str] = None + demand: float + return_factor: float + min_level: float + node_id: int class PumpStatic(BaseModel): @@ -59,13 +59,13 @@ class LevelBoundaryStatic(BaseModel): class UserTime(BaseModel): - remarks: Optional[str] = Field("", description="a hack for pandera") - priority: int = Field(..., description="priority") - time: datetime = Field(..., description="time") - demand: float = Field(..., description="demand") - return_factor: Any = Field(..., description="return_factor") - node_id: int = Field(..., description="node_id") - allocated: float = Field(..., description="allocated") + remarks: str = Field("", description="a hack for pandera") + priority: int + time: datetime + demand: float + return_factor: float + min_level: float + node_id: int class DiscreteControlCondition(BaseModel): @@ -218,8 +218,10 @@ class Root(BaseModel): DiscreteControlLogic: Optional[DiscreteControlLogic] = None Edge: Optional[Edge] = None FlowBoundaryTime: Optional[FlowBoundaryTime] = None + UserStatic: Optional[UserStatic] = None PumpStatic: Optional[PumpStatic] = None LevelBoundaryStatic: Optional[LevelBoundaryStatic] = None + UserTime: Optional[UserTime] = None DiscreteControlCondition: Optional[DiscreteControlCondition] = None BasinForcing: Optional[BasinForcing] = None FractionalFlowStatic: Optional[FractionalFlowStatic] = None @@ -237,5 +239,3 @@ class Root(BaseModel): BasinProfile: Optional[BasinProfile] = None TerminalStatic: Optional[TerminalStatic] = None BasinStatic: Optional[BasinStatic] = None - UserStatic: Optional[UserStatic] = None - UserTime: Optional[UserTime] = None