Code Duplication    Length = 16-17 lines in 3 locations

mycluster/slurm.py 1 location

@@ 311-327 (lines=17) @@
308
            if line in ["SLURM accounting storage is disabled",
309
                        "slurm_load_job error: Invalid job id specified"]:
310
                raise
311
            cols = line.split('|')
312
            stats_dict['job_id'] = cols[0]
313
            stats_dict['wallclock'] = get_timedelta(cols[1])
314
            stats_dict['cpu'] = get_timedelta(cols[2])
315
            stats_dict['queue'] = cols[3]
316
            stats_dict['status'] = cols[6]
317
            stats_dict['exit_code'] = cols[7].split(':')[0]
318
            stats_dict['start'] = cols[8]
319
            stats_dict['end'] = cols[9]
320
321
            steps = []
322
            for line in f:
323
                step = {}
324
                cols = line.split('|')
325
                step_val = cols[0].split('.')[1]
326
                step['step'] = step_val
327
                step['wallclock'] = get_timedelta(cols[1])
328
                step['cpu'] = get_timedelta(cols[2])
329
                step['ntasks'] = cols[4]
330
                step['status'] = cols[6]

mycluster/lsf.py 1 location

@@ 286-302 (lines=17) @@
283
                try:
284
                    output = f.readlines()
285
                    for line in output:
286
                        if "Done successfully" in line:
287
                            stats_dict['status'] = 'DONE'
288
                            return stats_dict
289
                        elif "Completed <exit>" in line:
290
                            stats_dict['status'] = 'EXIT'
291
                            return stats_dict
292
                        else:
293
                            stats_dict['status'] = 'UNKNOWN'
294
                except Exception as e:
295
                    print(e)
296
                    print('LSF: Error reading job stats')
297
                    stats_dict['status'] = 'UNKNOWN'
298
    return stats_dict
299
300
301
def running_stats(job_id):
302
    stats_dict = {}
303
    with os.popen('bjobs -W ' + str(job_id)) as f:
304
        try:
305
            line = f.readline()

mycluster/sge.py 1 location

@@ 402-417 (lines=16) @@
399
        except:
400
            pass
401
402
    stats_dict['wallclock'] = 0
403
    stats_dict['mem'] = output['mem']
404
    stats_dict['cpu'] = output['cpu']
405
406
    return stats_dict
407