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

Method setUp

tests/output_methods/test_http.py:82–129  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

80
81class TestCodeCarbonAPIOutput(unittest.TestCase):
82 def setUp(self):
83 self.emissions_data = EmissionsData(
84 timestamp="2023-01-01T00:00:00",
85 project_name="test_project",
86 run_id="test_run_id",
87 experiment_id="test_experiment_id",
88 duration=10,
89 emissions=0.5,
90 emissions_rate=0.05,
91 cpu_power=20,
92 gpu_power=30,
93 ram_power=5,
94 cpu_energy=200,
95 gpu_energy=300,
96 ram_energy=50,
97 energy_consumed=550,
98 water_consumed=0.1,
99 country_name="Testland",
100 country_iso_code="TS",
101 region="Test Region",
102 cloud_provider="Test Cloud",
103 cloud_region="test-cloud-1",
104 os="TestOS",
105 python_version="3.8",
106 codecarbon_version="2.0",
107 cpu_count=4,
108 cpu_model="Test CPU",
109 gpu_count=1,
110 gpu_model="Test GPU",
111 longitude=0,
112 latitude=0,
113 ram_total_size=16,
114 tracking_mode="machine",
115 on_cloud="true",
116 pue=1.5,
117 wue=0.5,
118 )
119 self.url = "http://test.com/emissions"
120 self.experiment_id = (
121 None # Set to None so that ApiClient won't attempt a run on initialisation
122 )
123 self.api_key = "test_key"
124
125 self.add_emission_patcher = patch(
126 "codecarbon.output_methods.http.ApiClient.add_emission"
127 )
128 self.mock_add_emission = self.add_emission_patcher.start()
129 self.addCleanup(self.add_emission_patcher.stop)
130
131 def test_codecarbon_api_output_initialization(self):
132 CodeCarbonAPIOutput(

Callers

nothing calls this directly

Calls 2

EmissionsDataClass · 0.90
startMethod · 0.45

Tested by

no test coverage detected