@@ -32,16 +32,16 @@ def test_clean_env_key(self):
3232
3333 def test_parse_gpu_ids (self ):
3434 for ids , target in [
35- ("0,1,2" , ["0" , "1" , "2" ]),
36- ("[0, 1, 2" , ["0" , "1" , "2" ]),
37- ("(0, 1, 2)" , ["0" , "1" , "2" ]),
38- ("[1]" , ["1" ]),
39- ("1" , ["1" ]),
40- ("0" , ["0" ]),
41- ("MIGf1e" , ["MIGf1e" ]),
35+ ("0,1,2" , [0 , 1 , 2 ]),
36+ ("[0, 1, 2" , [0 , 1 , 2 ]),
37+ ("(0, 1, 2)" , [0 , 1 , 2 ]),
38+ ("[1]" , [1 ]),
39+ ("1" , [1 ]),
40+ ("0" , [0 ]),
4241 ("" , []),
4342 ([], []),
44- ([1 , 2 , 3 ], ["1" , "2" , "3" ]),
43+ ([1 , 2 , 3 ], [1 , 2 , 3 ]),
44+ (1 , 1 ),
4545 ]:
4646 self .assertEqual (parse_gpu_ids (ids ), target )
4747
@@ -101,7 +101,6 @@ def test_read_confs(self):
101101 "USER" : "useless key" ,
102102 "CODECARBON_ENV_OVERWRITE" : "SUCCESS:overwritten" ,
103103 "CODECARBON_ENV_NEW_KEY" : "cool value" ,
104- "CODECARBON_ALLOW_MULTIPLE_RUNS" : "True" ,
105104 },
106105 )
107106 def test_read_confs_and_parse_envs (self ):
@@ -146,8 +145,9 @@ def test_empty_conf(self):
146145 "builtins.open" , new_callable = get_custom_mock_open (global_conf , local_conf )
147146 ):
148147 conf = dict (get_hierarchical_config ())
149- # allow_multiple_runs is set in pytest.ini and not mocked, so it's visible here.
150- target = {"allow_multiple_runs" : "True" }
148+ target = {
149+ "allow_multiple_runs" : "True"
150+ } # allow_multiple_runs is a default value
151151 self .assertDictEqual (conf , target )
152152
153153 @mock .patch .dict (
@@ -190,7 +190,7 @@ def test_full_hierarchy(self):
190190 self .assertEqual (tracker ._force_ram_power , 50.5 )
191191 self .assertEqual (tracker ._output_dir , "/success/overwritten" )
192192 self .assertEqual (tracker ._emissions_endpoint , "http://testhost:2000" )
193- self .assertEqual (tracker ._gpu_ids , ["0" , "1" ])
193+ self .assertEqual (tracker ._gpu_ids , [0 , 1 ])
194194 self .assertEqual (tracker ._co2_signal_api_token , "signal-token" )
195195 self .assertEqual (tracker ._project_name , "test-project" )
196196 self .assertTrue (tracker ._save_to_file )
@@ -206,7 +206,7 @@ def test_gpu_ids_from_env(self):
206206 tracker = EmissionsTracker (
207207 project_name = "test-project" , allow_multiple_runs = True
208208 )
209- self .assertEqual (tracker ._gpu_ids , ["2" , "3" ])
209+ self .assertEqual (tracker ._gpu_ids , [2 , 3 ])
210210
211211 @mock .patch .dict (
212212 os .environ ,
@@ -220,7 +220,7 @@ def test_too_much_gpu_ids_in_env(self):
220220 tracker = EmissionsTracker (
221221 project_name = "test-project" , allow_multiple_runs = True
222222 )
223- self .assertEqual (tracker ._gpu_ids , ["99" ])
223+ self .assertEqual (tracker ._gpu_ids , [99 ])
224224 gpu_count = 0
225225 for hardware in tracker ._hardware :
226226 if isinstance (hardware , GPU ):
0 commit comments