Skip to content

Commit 8868148

Browse files
author
benoit-cty
committed
after review fix
1 parent e458fcc commit 8868148

3 files changed

Lines changed: 3 additions & 174 deletions

File tree

codecarbon/core/rapl.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,7 @@ class RAPLFile:
2222
max_energy_reading: Energy = field(default_factory=lambda: Energy(0))
2323

2424
def __post_init__(self):
25-
try:
26-
self.last_energy = self._get_value()
27-
except Exception as e:
28-
# Be tolerant to permission / IO errors during initialization.
29-
# If we cannot read the initial energy, default to 0 and continue;
30-
# the caller will skip or produce zeros for this RAPL file.
31-
if isinstance(e, PermissionError):
32-
logger.warning(
33-
"Unable to read initial RAPL energy from %s due to permission error: %s",
34-
self.path,
35-
e,
36-
)
37-
else:
38-
logger.debug(
39-
"Unable to read initial RAPL energy from %s: %s",
40-
self.path,
41-
e,
42-
)
43-
self.last_energy = Energy.from_ujoules(0)
44-
25+
self.last_energy = self._get_value()
4526
try:
4627
with open(self.max_path, "r") as f:
4728
max_micro_joules = float(f.read())

codecarbon/output_methods/logger.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ def out(self, total: EmissionsData, delta: EmissionsData):
2424
logger.error(e, exc_info=True)
2525

2626
def live_out(self, total: EmissionsData, delta: EmissionsData):
27-
# Logger output should only be written on flush/stop (via out()),
28-
# not during periodic measurements to avoid duplicate log entries
29-
pass
27+
self.out(total, delta)
3028

3129

3230
class GoogleCloudLoggerOutput(LoggerOutput):
@@ -42,6 +40,4 @@ def out(self, total: EmissionsData, delta: EmissionsData):
4240
logger.error(e, exc_info=True)
4341

4442
def live_out(self, total: EmissionsData, delta: EmissionsData):
45-
# Logger output should only be written on flush/stop (via out()),
46-
# not during periodic measurements to avoid duplicate log entries
47-
pass
43+
self.out(total, delta)

examples/rapl/RAPL_FIX_SUMMARY.md

Lines changed: 0 additions & 148 deletions
This file was deleted.

0 commit comments

Comments
 (0)