in analysis/GreenSKU-Framework/src/carbon_model.py [0:0]
def index_cpu_data(vendor: str, cpu_type: str, core_count: int, data_source: str="data_sources") -> Dict[str, Any]:
"""Index the CPU data for a given vendor, CPU type, and core count.
Args:
vendor: The CPU vendor.
cpu_type: The CPU type.
core_count: The number of cores in the CPU.
data_source: The directory containing the CPU data.
Returns:
A dictionary containing the CPU data.
"""
cpu_data = read_yaml(join_path(data_source, 'CPU.yaml'))
data = None
spec_derates = None
for cpu_vendor in cpu_data:
if cpu_vendor['vendor'] != vendor:
continue
spec_derates = cpu_vendor['spec_derates']
for cpu_type_data in cpu_vendor['types']:
if cpu_type_data['type'] != cpu_type:
continue
for core_count_data in cpu_type_data['core_counts']:
if core_count_data['count'] != core_count:
continue
data = core_count_data
data['spec_derates'] = spec_derates
if 'carbon' not in data:
data['carbon'] = 0.0
if 'threads' not in data:
data['threads'] = 2
return data
raise ValueError(f'Could not find CPU data for {vendor} {cpu_type} with {core_count} cores.')