Skip to content

Commit 34d4af2

Browse files
committed
bump config version due to the recent new aiida options
1 parent 2fe4403 commit 34d4af2

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

examples/aiida_archive/optimade.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
config_version: 0.1.0
1+
config_version: 0.1.1
22

33
database_description: >-
44
This example aiida database contains optimized structures and band structure calculations.

src/optimade_maker/config.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
from pydantic import ConfigDict, field_validator, model_validator
88

99
IDENTIFIER_REGEX = r"^[a-z_][a-z_0-9]*$"
10-
__version__ = "0.1.0"
10+
__version__ = "0.1.1"
11+
_SUPPORTED_CONFIG_VERSIONS = {"0.1.0", "0.1.1"}
12+
1113

1214
from pathlib import Path
1315
from typing import Optional, Union
@@ -140,7 +142,7 @@ class Config(BaseModel):
140142
"""
141143

142144
config_version: str = Field(
143-
"0.1.0",
145+
__version__,
144146
description="The version of the `optimade.yaml` config specification.",
145147
)
146148

@@ -173,9 +175,22 @@ def from_string(data: str):
173175

174176
@model_validator(mode="before")
175177
@classmethod
176-
def validate_config_version(cls, values):
177-
if values.get("config_version") is None:
178-
raise UnsupportedConfigVersion(f"Config version must be {__version__}.")
178+
def validate_config_version(cls, values: dict):
179+
v = values.get("config_version")
180+
181+
# If missing, keep current behavior: require explicit version
182+
if v is None:
183+
raise UnsupportedConfigVersion(
184+
f"Missing config_version. Supported versions are: {sorted(_SUPPORTED_CONFIG_VERSIONS)}. "
185+
f"The current version is {__version__}."
186+
)
187+
188+
if v not in _SUPPORTED_CONFIG_VERSIONS:
189+
raise UnsupportedConfigVersion(
190+
f"Unsupported config_version {v!r}. "
191+
f"Supported versions are: {sorted(_SUPPORTED_CONFIG_VERSIONS)}."
192+
)
193+
179194
return values
180195

181196
model_config = ConfigDict(extra="forbid")

0 commit comments

Comments
 (0)