singhalamaan116 commited on
Commit
b0cc1a1
·
verified ·
1 Parent(s): 4751408

Update ecoeval/energy.py

Browse files
Files changed (1) hide show
  1. ecoeval/energy.py +8 -1
ecoeval/energy.py CHANGED
@@ -1,4 +1,5 @@
1
  # ecoeval/energy.py
 
2
  from typing import Callable, Dict, Any
3
 
4
  from codecarbon import EmissionsTracker
@@ -11,13 +12,19 @@ def run_with_energy(
11
  """
12
  Wrap any benchmark function with CodeCarbon energy & emissions tracking.
13
  """
 
 
 
 
 
14
  tracker = EmissionsTracker(
15
  project_name=project_name,
16
  measure_power_secs=1,
17
- output_dir="emissions",
18
  save_to_file=True,
19
  log_level="error",
20
  )
 
21
  tracker.start()
22
  metrics = fn()
23
  emissions = tracker.stop()
 
1
  # ecoeval/energy.py
2
+ import os
3
  from typing import Callable, Dict, Any
4
 
5
  from codecarbon import EmissionsTracker
 
12
  """
13
  Wrap any benchmark function with CodeCarbon energy & emissions tracking.
14
  """
15
+
16
+ # 🔧 Ensure the output directory exists (this fixes your OSError)
17
+ output_dir = "emissions"
18
+ os.makedirs(output_dir, exist_ok=True)
19
+
20
  tracker = EmissionsTracker(
21
  project_name=project_name,
22
  measure_power_secs=1,
23
+ output_dir=output_dir,
24
  save_to_file=True,
25
  log_level="error",
26
  )
27
+
28
  tracker.start()
29
  metrics = fn()
30
  emissions = tracker.stop()