-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from databio/dev
Release v0.10.3
- Loading branch information
Showing
6 changed files
with
152 additions
and
10 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.10.2" | ||
__version__ = "0.10.3" |
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,5 +1,4 @@ | ||
import logging | ||
|
||
from functools import cached_property | ||
from pathlib import Path | ||
from typing import List, Union | ||
|
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,64 @@ | ||
import yacman | ||
from pephubclient.helpers import MessageHandler as m | ||
from pydantic_core._pydantic_core import ValidationError | ||
|
||
from bbconf.config_parser.models import ConfigFile | ||
from bbconf.exceptions import BedBaseConfError | ||
from bbconf.helpers import get_bedbase_cfg | ||
|
||
|
||
def config_analyzer(config_path: str) -> bool: | ||
""" | ||
Read configuration file and insert default values if not set | ||
:param config_path: configuration file path | ||
:return: None | ||
:raises: raise_missing_key (if config key is missing) | ||
""" | ||
config_path = get_bedbase_cfg(config_path) | ||
|
||
print("Analyzing the configuration file {config_path}...") | ||
|
||
_config = yacman.YAMLConfigManager(filepath=config_path).exp | ||
|
||
config_dict = {} | ||
for field_name, annotation in ConfigFile.model_fields.items(): | ||
try: | ||
config_dict[field_name] = annotation.annotation(**_config.get(field_name)) | ||
except TypeError: | ||
if annotation.is_required(): | ||
print( | ||
str( | ||
BedBaseConfError( | ||
f"`Config info: {field_name}` Field is not set in the configuration file or missing. " | ||
) | ||
) | ||
) | ||
else: | ||
print( | ||
f"Config info: `{field_name}` Field is not set in the configuration file. Using default value." | ||
) | ||
try: | ||
config_dict[field_name] = None | ||
except ValidationError as e: | ||
print( | ||
str( | ||
BedBaseConfError( | ||
f"Error in provided configuration file. Section: `{field_name}` missing values :: \n {e}" | ||
) | ||
) | ||
) | ||
return False | ||
except ValidationError as e: | ||
print( | ||
str( | ||
BedBaseConfError( | ||
f"Error in provided configuration file. Section: `{field_name}` missing values :: \n {e}" | ||
) | ||
) | ||
) | ||
return False | ||
|
||
m.print_success("Configuration file is valid! ") | ||
|
||
return True |
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