Skip to content

Commit 50c087a

Browse files
committed
Avoids the issue of pd.timedelta.sum() overflowing
1 parent b555aa4 commit 50c087a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

GreenAlgorithms_global.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ def generate_report(self):
251251
totalEnergy = self.df.energy.sum()
252252
dcOverheads = totalEnergy - self.df.energy_CPUs.sum() - self.df.energy_GPUs.sum() - self.df.energy_memory.sum()
253253

254+
### pd.timedelta.sum() has a limit on the number of timedeltas that can be summed up, so going around this limitation with this
255+
TotalCPUtime2use_sec = self.df.TotalCPUtime2useX.dt.total_seconds()
256+
TotalGPUtime2use_sec = self.df.TotalGPUtime2useX.dt.total_seconds()
257+
WallclockTime_sec = self.df.WallclockTimeX.dt.total_seconds()
258+
254259
self.report = f'''
255260
############################{'#'*len(clusterName)}###
256261
# {' '*len(clusterName)} #
@@ -283,9 +288,9 @@ def generate_report(self):
283288
- Number of jobs: {len(self.df):,} ({len(self.df.loc[self.df.StateX == 1]):,} completed)
284289
- Core hours used/charged: {CPU_ch:,.1f} (CPU), {GPU_ch:,.1f} (GPU), {CPU_ch+GPU_ch:,.1f} (total).
285290
- Total usage time (i.e. when cores were performing computations):
286-
- CPU: {str(self.df.TotalCPUtime2useX.sum())}
287-
- GPU: {str(self.df.TotalGPUtime2useX.sum())}
288-
- Total wallclock time: {str(self.df.WallclockTimeX.sum())}
291+
- CPU: {str(datetime.timedelta(seconds=TotalCPUtime2use_sec.sum()))}
292+
- GPU: {str(datetime.timedelta(seconds=TotalGPUtime2use_sec.sum()))}
293+
- Total wallclock time: {str(datetime.timedelta(seconds=WallclockTime_sec.sum()))}
289294
- Total memory requested: {self.df.ReqMemX.sum():,.0f} GB
290295
291296
Limitations to keep in mind:

0 commit comments

Comments
 (0)