File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def set_CPU_tracking(self):
4141 logger .info ("[setup] CPU Tracking..." )
4242 cpu_number = self .tracker ._conf .get ("cpu_physical_count" )
4343 tdp = cpu .TDP ()
44- max_power = tdp .tdp * cpu_number
44+ max_power = tdp .tdp * cpu_number if tdp . tdp is not None else None
4545 if self .tracker ._conf .get ("force_mode_cpu_load" , False ) and tdp .tdp is not None :
4646 if tdp .tdp is None :
4747 logger .warning (
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ def count_physical_cpus():
127127 for line in output .split ("\n " ):
128128 if "Socket(s):" in line :
129129 return int (line .split (":" )[1 ].strip ())
130+ return 1
130131 except Exception as e :
131132 logger .warning (
132133 f"Error while trying to count physical CPUs: { e } . Defaulting to 1."
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ def test_carbon_tracker_offline_constant(self):
6666 @mock .patch .object (cpu .TDP , "_get_cpu_power_from_registry" )
6767 @mock .patch .object (cpu , "is_psutil_available" )
6868 def test_carbon_tracker_offline_constant_default_cpu_power (
69- self , mock_tdp , mock_psutil
69+ self , mock_psutil , mock_tdp
7070 ):
7171 # Same as test_carbon_tracker_offline_constant test but this time forcing the default cpu power
7272 USER_INPUT_CPU_POWER = 1_000
@@ -78,6 +78,7 @@ def test_carbon_tracker_offline_constant_default_cpu_power(
7878 output_dir = self .emissions_path ,
7979 output_file = self .emissions_file ,
8080 default_cpu_power = USER_INPUT_CPU_POWER ,
81+ allow_multiple_runs = True ,
8182 )
8283 tracker .start ()
8384 heavy_computation (run_time_secs = 1 )
You can’t perform that action at this time.
0 commit comments