MCPcopy Create free account
hub / github.com/mlco2/codecarbon / _load_static_data

Function _load_static_data

codecarbon/input.py:31–59  ·  view source on GitHub ↗

Load all static reference data at module import. Called once when codecarbon is imported. All data loaded here is immutable and shared across all tracker instances.

()

Source from the content-addressed store, hash-verified

29
30
31def _load_static_data() -> None:
32 """
33 Load all static reference data at module import.
34
35 Called once when codecarbon is imported. All data loaded here
36 is immutable and shared across all tracker instances.
37 """
38 # Global energy mix - used for emissions calculations
39 path = _get_resource_path("data/private_infra/global_energy_mix.json")
40 with open(path) as f:
41 _CACHE["global_energy_mix"] = json.load(f)
42
43 # Cloud emissions data
44 path = _get_resource_path("data/cloud/impact.csv")
45 _CACHE["cloud_emissions"] = pd.read_csv(path)
46
47 # Carbon intensity per source
48 path = _get_resource_path("data/private_infra/carbon_intensity_per_source.json")
49 with open(path) as f:
50 _CACHE["carbon_intensity_per_source"] = json.load(f)
51
52 # CPU power data
53 path = _get_resource_path("data/hardware/cpu_power.csv")
54 _CACHE["cpu_power"] = pd.read_csv(path)
55
56 # Nordic country energy mix - used for emissions calculations
57 path = _get_resource_path("data/private_infra/nordic_emissions.json")
58 with open(path) as f:
59 _CACHE["nordic_country_energy_mix"] = json.load(f)
60
61
62# Load static data at module import

Callers 1

input.pyFile · 0.85

Calls 1

_get_resource_pathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…