in cluster-trace-gpu-v2020/simulator/utils.py [0:0]
def _add_job(job_list, job_dict, describe_dict=None):
# Add job (job_dict) into job_list
for key, value in job_dict.items():
if value is not None and value.isdigit() and key != 'user':
if type(value) == str:
job_dict[key] = round(float(value))
else: # duration becomes an int
job_dict[key] = round(value)
elif key in ['wait_time','user_dur','user_gpu_dur','group_dur','group_gpu_dur']:
try:
job_dict[key] = float(value)
except:
pass
keys = ['num_cpu', 'num_gpu', 'submit_time', 'num_inst']
for key in keys:
if key not in job_dict or job_dict[key] == '':
if key in ['num_cpu', 'num_gpu']:
job_dict[key] = 0
else: # key in ['submit_time', 'num_inst']
job_dict[key] = 1
else:
if key in ['num_cpu', 'num_gpu']: # in %
job_dict[key] = round(100 * float(job_dict[key]))
else:
job_dict[key] = round(float(job_dict[key]))
# Add entries to be used in scheduling
job_dict['duration'] = int(float(job_dict['duration']))
if job_dict['duration'] <= 0:
job_dict['duration'] = 1 # fix duration == 0 problem.
job_dict['size'] = int((job_dict['num_gpu'] + job_dict['num_cpu']) * job_dict['duration']) # (gpu + cpu) x duration
job_dict['on_time'] = 0
job_dict['wasted'] = 0
job_dict['jct'] = -1
job_dict['resource'] = [job_dict['num_gpu'], job_dict['num_cpu']] # list of resources
job_dict['node'] = None
# Add duration estimation
if describe_dict is not None:
jd_user = describe_dict.get(job_dict['user'])
if jd_user is not None:
job_dict['dur_avg'] = float(jd_user['mean']) # expectation
job_dict['dur_std'] = float(jd_user['std']) # standard deviation
job_dict['dur_med'] = float(jd_user['50%']) # median
job_dict['dur_trim_mean'] = float(jd_user['trim_mean']) # discard 10% top and 10% tail when calc. mean
# Remove original unused entries
for drop_col in ['fuxi_job_name','fuxi_task_name','inst_id','running_cluster','model_name','iterations','interval','vc','jobid','status']:
if drop_col in job_dict: job_dict.pop(drop_col)
job_list.append(job_dict)