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

Commit e4a463a

Browse files
committed
Revert c2d4b6a
1 parent 2dd6a31 commit e4a463a

2 files changed

Lines changed: 20 additions & 23 deletions

File tree

src/scripts/pbs_status.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,25 +329,24 @@ def get_finished_job_stats(jobid):
329329
except Exception, e:
330330
log("Unable to read in CSV output from sacct: %s" % str(e))
331331
return return_dict
332-
333-
sacct_parser = {'RemoteUserCpu': lambda orig, results: orig + \
334-
convert_cpu_to_seconds(results["AveCPU"]) * int(results["AllocCPUS"]),
335-
'ImageSize': lambda orig, results: orig + int(results["MaxRSS"].replace('K', '')),
336-
'ExitCode': lambda orig, results: int(results["ExitCode"].split(":")[0])}
332+
337333
# Slurm can return more than 1 row, for some odd reason.
338334
# so sum up relevant values
339335
for row in reader:
340-
for attr, func in sacct_parser.items():
341-
try:
342-
return_dict[attr] = func(return_dict[attr], row)
343-
except (ValueError, KeyError), exc:
344-
log("Could not parse %s for Jobid %s: %s" % (attr, jobid, exc))
345-
346-
# PBS completion
336+
if row["AveCPU"] is not "":
337+
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
338+
if row["MaxRSS"] is not "":
339+
# Remove the trailing 'K'
340+
return_dict["ImageSize"] += int(row["MaxRSS"].replace('K', ''))
341+
if row["ExitCode"] is not "":
342+
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
343+
344+
# PBS completion
347345
elif _cluster_type_cache == "pbs":
348346
pass
349347

350348
return return_dict
349+
351350

352351
_qstat_location_cache = None
353352
def get_qstat_location():

src/scripts/slurm_status.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,20 @@ def get_finished_job_stats(jobid):
318318
except Exception, e:
319319
log("Unable to read in CSV output from sacct: %s" % str(e))
320320
return return_dict
321-
322-
sacct_parser = {'RemoteUserCpu': lambda orig, results: orig + \
323-
convert_cpu_to_seconds(results["AveCPU"]) * int(results["AllocCPUS"]),
324-
'ImageSize': lambda orig, results: orig + int(results["MaxRSS"].replace('K', '')),
325-
'ExitCode': lambda orig, results: int(results["ExitCode"].split(":")[0])}
321+
326322
# Slurm can return more than 1 row, for some odd reason.
327323
# so sum up relevant values
328324
for row in reader:
329-
for attr, func in sacct_parser.items():
330-
try:
331-
return_dict[attr] = func(return_dict[attr], row)
332-
except (ValueError, KeyError), exc:
333-
log("Could not parse %s for Jobid %s: %s" % (attr, jobid, exc))
325+
if row["AveCPU"] is not "":
326+
return_dict['RemoteUserCpu'] += convert_cpu_to_seconds(row["AveCPU"]) * int(row["AllocCPUS"])
327+
if row["MaxRSS"] is not "":
328+
# Remove the trailing 'K'
329+
return_dict["ImageSize"] += int(row["MaxRSS"].replace('K', ''))
330+
if row["ExitCode"] is not "":
331+
return_dict["ExitCode"] = int(row["ExitCode"].split(":")[0])
334332

335333
return return_dict
336-
334+
337335

338336
_slurm_location_cache = None
339337
def get_slurm_location(program):

0 commit comments

Comments
 (0)