aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/backend/config.py
blob: 9a56fa9f7399b71094c8aedc3336891ab1319fbb (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Contain definition of backend configuration."""
from pathlib import Path
from typing import Dict
from typing import List
from typing import Optional
from typing import TypedDict
from typing import Union


class UserParamConfig(TypedDict, total=False):
    """User parameter configuration."""

    name: Optional[str]
    default_value: str
    values: List[str]
    description: str
    alias: str


UserParamsConfig = Dict[str, List[UserParamConfig]]


class ExecutionConfig(TypedDict, total=False):
    """Execution configuration."""

    commands: Dict[str, List[str]]
    user_params: UserParamsConfig
    variables: Dict[str, str]


class NamedExecutionConfig(ExecutionConfig):
    """Execution configuration with name."""

    name: str


class BaseBackendConfig(ExecutionConfig, total=False):
    """Base backend configuration."""

    name: str
    description: str
    config_location: Path
    annotations: Dict[str, Union[str, List[str]]]


class ApplicationConfig(BaseBackendConfig, total=False):
    """Application configuration."""

    supported_systems: List[str]


class ExtendedApplicationConfig(BaseBackendConfig, total=False):
    """Extended application configuration."""

    supported_systems: List[NamedExecutionConfig]


class SystemConfig(BaseBackendConfig, total=False):
    """System configuration."""

    reporting: Dict[str, Dict]


BackendItemConfig = Union[ApplicationConfig, SystemConfig]
BackendConfig = Union[List[ExtendedApplicationConfig], List[SystemConfig]]