-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Convert config template to pydantic model
- Loading branch information
1 parent
1dd9f84
commit 8f34a29
Showing
31 changed files
with
292 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
.idea | ||
config/* | ||
!config/config_template.yaml | ||
.history | ||
**/__pycache__/ | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import logging | ||
|
||
import jsonschema | ||
import jsonschema.exceptions | ||
|
||
from . import exceptions, loader | ||
from . import loader, models | ||
|
||
log = logging.getLogger(__name__) | ||
config = loader.load_yaml() | ||
|
||
|
||
def validate_schema(): | ||
config_schema = loader.load_config_schema() | ||
try: | ||
jsonschema.validate(config, config_schema) | ||
except jsonschema.exceptions.ValidationError as error: | ||
raise exceptions.InvalidConfigurationError( | ||
f"{error.__class__.__name__}: {error.message}", | ||
) from None | ||
config_data = loader.load_yaml() | ||
config = models.AppConfig(**config_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import yaml | ||
|
||
from . import models | ||
|
||
app_config = models.AppConfig() | ||
config_dict = app_config.model_dump() | ||
yaml_str = yaml.dump(config_dict, sort_keys=False) | ||
|
||
with open( | ||
"backend/capellacollab/config/config.yaml", "w", encoding="utf-8" | ||
) as yaml_file: | ||
yaml_file.write(yaml_str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.