Extract code to load config from YAML file into new utils.yaml module

This commit is contained in:
Debanjum Singh Solanky
2022-08-10 20:07:00 +03:00
parent daef276fd1
commit d2c7b28172
2 changed files with 18 additions and 12 deletions

15
src/utils/yaml.py Normal file
View File

@@ -0,0 +1,15 @@
# External Packages
import yaml
# Internal Packages
from src.utils.helpers import get_absolute_path
from src.utils.rawconfig import FullConfig
def load_config_from_file(yaml_config_file):
# Read Config from YML file
config_from_file = None
with open(get_absolute_path(yaml_config_file), 'r', encoding='utf-8') as config_file:
config_from_file = yaml.safe_load(config_file)
# Parse, Validate Config in YML file
return FullConfig.parse_obj(config_from_file)