File size: 950 Bytes
2fcb72a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Any, Dict, List, Optional

import yaml


class HardwareConfig:
    def __init__(self, data: Dict[str, Any]):
        self.machine: str = data["machine"]
        self.hardware_provider: str = data["hardware_provider"]
        self.hardware_type: str = data["hardware_type"]
        self.subsets: List[str] = data["subsets"]
        self.backends: List[str] = data["backends"]
        self.detail: Optional[str] = data.get("detail", None)

    def __repr__(self) -> str:
        return (
            f"HardwareConfig(machine='{self.machine}', description='{self.description}', "
            f"hardware_provider={self.hardware_provider}, hardware_type={self.hardware_type}, subsets={self.subsets}, backends={self.backends})"
        )


def load_hardware_configs(file_path: str) -> List[HardwareConfig]:
    with open(file_path, "r") as file:
        data = yaml.safe_load(file)
    return [HardwareConfig(config) for config in data]