From 7913ff11b22dc6af9a7fbff4d79f66e62d854378 Mon Sep 17 00:00:00 2001 From: Jan Ivar Korsbakken Date: Thu, 17 Oct 2024 07:43:24 +0200 Subject: [PATCH] Read dimensions other than `variable` and `region` from external repo (#415) --- nomenclature/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nomenclature/config.py b/nomenclature/config.py index 4d20d32e..0bae16b8 100644 --- a/nomenclature/config.py +++ b/nomenclature/config.py @@ -122,10 +122,12 @@ class DataStructureConfig(BaseModel): """ + model: Optional[CodeListConfig] = Field(default_factory=CodeListConfig) + scenario: Optional[CodeListConfig] = Field(default_factory=CodeListConfig) region: Optional[RegionCodeListConfig] = Field(default_factory=RegionCodeListConfig) variable: Optional[CodeListConfig] = Field(default_factory=CodeListConfig) - @field_validator("region", "variable", mode="before") + @field_validator("model", "scenario", "region", "variable", mode="before") @classmethod def add_dimension(cls, v, info: ValidationInfo): return {"dimension": info.field_name, **v} @@ -134,7 +136,7 @@ def add_dimension(cls, v, info: ValidationInfo): def repos(self) -> dict[str, str]: return { dimension: getattr(self, dimension).repositories - for dimension in ("region", "variable") + for dimension in ("model", "scenario", "region", "variable") if getattr(self, dimension).repositories }