File size: 861 Bytes
3989022
 
 
a568da9
3989022
 
a568da9
3989022
 
536a116
3989022
 
536a116
3989022
 
 
 
536a116
 
3989022
536a116
 
 
 
 
 
3989022
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-

from pathlib import Path

from teklia_toolbox.config import ConfigParser


def parse_configurations(config_path: Path):
    """
    Parse multiple YAML configuration files into a single source
    of configuration for the HuggingFace app

    :param config_path: pathlib.Path, Path to the .yaml config file
    :return: dict, containing the configuration. Ensures config is complete and with correct typing
    """
    parser = ConfigParser()

    parser.add_option("title")
    parser.add_option("description")
    parser.add_option("examples", type=list)
    model_parser = parser.add_subparser("models", many=True)

    model_parser.add_option("model_name")
    model_parser.add_option("title")
    model_parser.add_option("description")
    model_parser.add_option("classes_colors", type=list)

    return parser.parse(config_path)