Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

Commit aa755f0

Browse files
committed
Log any parsing exceptions
1 parent 7cc0816 commit aa755f0

2 files changed

Lines changed: 51 additions & 28 deletions

File tree

src/scripts/pbs_status.py

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,25 +334,37 @@ def get_finished_job_stats(jobid):
334334
# so sum up relevant values
335335
for row in reader:
336336
if row["AveCPU"] is not "":
337-
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
337+
try:
338+
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
339+
except:
340+
log("Failed to parse CPU usage for job id %s: %s, %s" % (jobid, row["AveCPU"], row["AllocCPUS"]))
341+
raise
338342
if row["MaxRSS"] is not "":
339343
# Remove the trailing [KMGTP] and scale the value appropriately
340344
# Note: We assume that all values will have a suffix, and we
341345
# want the value in kilos.
342-
value = row["MaxRSS"]
343-
factor = 1
344-
if value[-1] == 'M':
345-
factor = 1024
346-
elif value[-1] == 'G':
347-
factor = 1024 * 1024
348-
elif value[-1] == 'T':
349-
factor = 1024 * 1024 * 1024
350-
elif value[-1] == 'P':
351-
factor = 1024 * 1024 * 1024 * 1024
352-
return_dict["ImageSize"] += int(value.strip('KMGTP')) * factor
346+
try:
347+
value = row["MaxRSS"]
348+
factor = 1
349+
if value[-1] == 'M':
350+
factor = 1024
351+
elif value[-1] == 'G':
352+
factor = 1024 * 1024
353+
elif value[-1] == 'T':
354+
factor = 1024 * 1024 * 1024
355+
elif value[-1] == 'P':
356+
factor = 1024 * 1024 * 1024 * 1024
357+
return_dict["ImageSize"] += int(value.strip('KMGTP')) * factor
358+
except:
359+
log("Failed to parse memory usage for job id %s: %s" % (jobid, row["MaxRSS"]))
360+
raise
353361
if row["ExitCode"] is not "":
354-
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
355-
362+
try:
363+
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
364+
except:
365+
log("Failed to parse ExitCode for job id %s: %s" % (jobid, row["ExitCode"]))
366+
raise
367+
356368
# PBS completion
357369
elif _cluster_type_cache == "pbs":
358370
pass

src/scripts/slurm_status.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,36 @@ def get_finished_job_stats(jobid):
323323
# so sum up relevant values
324324
for row in reader:
325325
if row["AveCPU"] is not "":
326-
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
326+
try:
327+
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
328+
except:
329+
log("Failed to parse CPU usage for job id %s: %s, %s" % (jobid, row["AveCPU"], row["AllocCPUS"]))
330+
raise
327331
if row["MaxRSS"] is not "":
328332
# Remove the trailing [KMGTP] and scale the value appropriately
329333
# Note: We assume that all values will have a suffix, and we
330334
# want the value in kilos.
331-
value = row["MaxRSS"]
332-
factor = 1
333-
if value[-1] == 'M':
334-
factor = 1024
335-
elif value[-1] == 'G':
336-
factor = 1024 * 1024
337-
elif value[-1] == 'T':
338-
factor = 1024 * 1024 * 1024
339-
elif value[-1] == 'P':
340-
factor = 1024 * 1024 * 1024 * 1024
341-
return_dict["ImageSize"] += int(value.strip('KMGTP')) * factor
335+
try:
336+
value = row["MaxRSS"]
337+
factor = 1
338+
if value[-1] == 'M':
339+
factor = 1024
340+
elif value[-1] == 'G':
341+
factor = 1024 * 1024
342+
elif value[-1] == 'T':
343+
factor = 1024 * 1024 * 1024
344+
elif value[-1] == 'P':
345+
factor = 1024 * 1024 * 1024 * 1024
346+
return_dict["ImageSize"] += int(value.strip('KMGTP')) * factor
347+
except:
348+
log("Failed to parse memory usage for job id %s: %s" % (jobid, row["MaxRSS"]))
349+
raise
342350
if row["ExitCode"] is not "":
343-
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
344-
351+
try:
352+
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
353+
except:
354+
log("Failed to parse memory usage for job id %s: %s" % (jobid, row["MaxRSS"]))
355+
raise
345356
return return_dict
346357

347358

0 commit comments

Comments
 (0)