提交 85a9ff59 编写于 作者: G gaoruoshu 提交者: g00563147

fix bug; add best performance chart

change file name before tuning start
update .spec
上级 97f8a043
......@@ -16,6 +16,9 @@ Provide an interface to read data from csv.
"""
import os
import re
import time
import random
import logging
import tarfile
import pandas as pd
......@@ -51,3 +54,15 @@ def add_data_to_file(data, mode, filename):
file_handle.write(str(data))
file_handle.write("\n")
file_handle.close()
def change_file_name():
"""change tuning file name"""
path = "/etc/atuned/webserver/"
file_list = os.listdir(path)
file_list.sort(key=lambda fn: os.path.getmtime(path + fn))
if len(file_list) > 0 and re.match(r'\S*-\d{17}\S*', file_list[-1]) is None:
old_name = file_list[-1].split(".")[0]
curr_time = time.strftime("%Y%m%d%H%M%S", time.localtime())
new_name = old_name + "-" + str(curr_time) + str(random.randint(100, 999))
os.rename(path + old_name + ".txt", path + new_name + ".txt")
......@@ -233,6 +233,8 @@ class Optimizer(multiprocessing.Process):
performance.append(x_num)
return x_num
utils.change_file_name()
params = {}
options = []
performance = []
......
......@@ -105,11 +105,13 @@ atune engine tool for manage atuned AI tuning system.
%defattr(0640,root,root,-)
%attr(0640,root,root) %{_unitdir}/atune-engine.service
%attr(0750,root,root) /usr/libexec/atuned/analysis/*
%attr(0750,root,root) /usr/libexec/atuned/resources/*
%attr(0750,root,root) /etc/atuned/*
%exclude /usr/libexec/atuned/analysis/app.py
%exclude /usr/libexec/atuned/analysis/plugin/
%exclude /usr/libexec/atuned/analysis/atuned/
%attr(0750,root,root) %dir /usr/libexec/atuned/analysis
%attr(0750,root,root) %dir /usr/libexec/atuned/resources
%attr(0640,root,root) %dir /etc/atuned
%post
......
......@@ -71,7 +71,15 @@ function updateChart(name, times, value) {
var oldX = chart.getOption().xAxis[0].data;
for (var i in times) {
oldX.push(times[i]);
oldData.push(value[i]);
if (name === 'best performance') {
if (parseInt(value[i], 10) > parseInt(oldData[oldData.length - 1], 10) || oldData[0] === undefined) {
oldData.push(value[i]);
} else {
oldData.push(oldData[oldData.length - 1]);
}
} else {
oldData.push(value[i]);
}
}
chart.setOption({
xAxis: {data: oldX},
......@@ -93,13 +101,15 @@ function appendPrjList(list, timestamp) {
}
var ul = document.createElement('ul');
container.appendChild(ul);
for (var i in list) {
for (let i in list) {
var li = document.createElement('li');
li.id = 'project-name-' + list[i];
li.appendChild(document.createTextNode(list[i]));
ul.appendChild(li);
li.style.cursor = 'pointer';
li.onclick = function () {
console.log(list[i]);
socket.emit('inital_chart', {'prj_name': list[i]}, timestamp, namespace = '/tuning');
};
}
......@@ -114,6 +124,9 @@ function updateChartInit(nameList, lineNum, value) {
}
for (var i in value) {
updateChart(nameList[i], lineList, value[i]);
if (nameList[i] === 'performance') {
updateChart('best performance', lineList, value[i]);
}
}
}
......
......@@ -16,11 +16,13 @@ Web UI initialization
"""
from flask import Flask, render_template
from flask_socketio import SocketIO
import os
import numpy
import logging
from flask import Flask, render_template
from flask_socketio import SocketIO
from configparser import ConfigParser
APP = Flask(__name__, template_folder='./templates', static_folder='./static')
APP.config['TEMPLATES_AUTO_RELOAD'] = True
......@@ -45,6 +47,7 @@ def show_page(timestamp, _):
"""list all tuning project name on page"""
path = '/etc/atuned/webserver'
filelist = os.listdir(path)
filelist.sort(key=lambda fn: os.path.getmtime(path + '/' + fn), reverse=True)
res = []
for each in filelist:
res.append(each.split('.')[0])
......@@ -101,4 +104,6 @@ def update_tuning_page(prj_name, num, timestamp, _):
if __name__ == '__main__':
socketio.run(APP, host='9.41.51.85', port=10086)
config = ConfigParser()
config.read('/etc/atuned/atuned.cnf')
socketio.run(APP, host=config.get("server", "engine_host"), port=10086)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册