提交 5c260bba 编写于 作者: Q Qiao Longfei 提交者: GitHub

Reorgnize server (#43)

* init logdir runs tags and scalars interface

* add debug

* add one mock data

* add dir server

* move frontend to server

* optimizer python package

* add mock data

* add back result encode

* use application/json as Response type

* rm .DS_Store

* update mock tags

* update mock data
上级 8dbaac0f
...@@ -99,3 +99,5 @@ ENV/ ...@@ -99,3 +99,5 @@ ENV/
# mypy # mypy
.mypy_cache/ .mypy_cache/
.DS_Store
from setuptools import setup from setuptools import setup
packages = ['visualdl', 'visualdl.frontend.dist', 'visualdl.mock']
setup( setup(
name="visualdl", name="visualdl",
version="0.0.1", version="0.0.1",
packages=['visualdl'], packages=packages,
package_data={'visualdl.frontend.dist': ['*', 'fonts/*']},
include_package_data=True, include_package_data=True,
install_requires=['flask>=0.12.1'], install_requires=['flask>=0.12.1'],
url='http://www.baidu.com/', url='http://www.baidu.com/',
license='Apache 2.0', ) license='Apache 2.0')
def sequence_data():
return [[1465980660.726887, 1, 0.07000000029802322],
[1465980660.767164, 2, 0.18000000715255737],
[1465980660.799817, 3, 0.3199999928474426],
[1465980660.831853, 4, 0.33000001311302185],
[1465980660.86555, 5, 0.3400000035762787],
[1465980660.898716, 6, 0.6000000238418579],
[1465980660.930804, 7, 0.6299999952316284],
[1465980660.963156, 8, 0.6299999952316284],
[1465980660.995727, 9, 0.6299999952316284],
[1465980661.603699, 11, 0.75],
[1465980661.641232, 12, 0.7900000214576721],
[1465980661.674311, 13, 0.7099999785423279],
[1465980661.704281, 14, 0.7099999785423279],
[1465980661.737259, 15, 0.7200000286102295],
[1465980661.768047, 16, 0.75],
[1465980661.801236, 17, 0.8600000143051147],
[1465980661.832749, 18, 0.7799999713897705],
[1465980661.862822, 19, 0.8399999737739563],
[1465980662.481258, 21, 0.699999988079071],
[1465980662.521448, 22, 0.6700000166893005],
[1465980662.557197, 23, 0.7699999809265137],
[1465980662.593898, 24, 0.7900000214576721],
[1465980662.629991, 25, 0.7200000286102295],
[1465980662.671198, 26, 0.8100000023841858],
[1465980662.711186, 27, 0.7599999904632568],
[1465980662.750267, 28, 0.7799999713897705],
[1465980662.791909, 29, 0.8299999833106995],
[1465980663.47027, 31, 0.8100000023841858],
[1465980663.538732, 32, 0.8500000238418579],
[1465980663.57077, 33, 0.8600000143051147],
[1465980663.60126, 34, 0.8199999928474426],
[1465980663.631059, 35, 0.7900000214576721],
[1465980663.665972, 36, 0.7799999713897705],
[1465980663.697275, 37, 0.9100000262260437],
[1465980663.726395, 38, 0.8700000047683716],
[1465980663.760169, 39, 0.9200000166893005],
[1465980664.45205, 41, 0.8299999833106995],
[1465980664.484207, 42, 0.7599999904632568],
[1465980664.515375, 43, 0.7699999809265137],
[1465980664.547608, 44, 0.8299999833106995],
[1465980664.580122, 45, 0.949999988079071],
[1465980664.611019, 46, 0.8999999761581421],
[1465980664.642956, 47, 0.8700000047683716],
[1465980664.674636, 48, 0.8500000238418579],
[1465980664.705622, 49, 0.8899999856948853],
[1465980665.379549, 51, 0.8399999737739563],
[1465980665.422869, 52, 0.8500000238418579],
[1465980665.466136, 53, 0.8199999928474426],
[1465980665.508361, 54, 0.9300000071525574],
[1465980665.544331, 55, 0.9399999976158142],
[1465980665.589887, 56, 0.8700000047683716],
[1465980665.633466, 57, 0.9300000071525574],
[1465980665.674978, 58, 0.7799999713897705],
[1465980665.716878, 59, 0.9300000071525574],
[1465980666.653456, 61, 0.8799999952316284],
[1465980666.697294, 62, 0.9300000071525574],
[1465980666.742066, 63, 0.8700000047683716],
[1465980666.780127, 64, 0.8299999833106995],
[1465980666.818287, 65, 0.9200000166893005],
[1465980666.855386, 66, 0.9399999976158142],
[1465980666.897352, 67, 0.9300000071525574],
[1465980666.931322, 68, 0.8899999856948853],
[1465980666.96562, 69, 0.8600000143051147],
[1465980667.619625, 71, 0.8700000047683716],
[1465980667.655166, 72, 0.9200000166893005], [
1465980667.687101, 73, 0.8199999928474426
], [1465980667.720176, 74, 0.8100000023841858],
[1465980667.751985, 75, 0.8500000238418579], [
1465980667.785244, 76, 0.8600000143051147
], [1465980667.820445, 77, 0.9200000166893005], [
1465980667.857163, 78, 0.8899999856948853
], [1465980667.891868, 79, 0.8999999761581421], [
1465980668.56409, 81, 0.8500000238418579
], [1465980668.599529, 82, 0.8299999833106995], [
1465980668.630751, 83, 0.8500000238418579
], [1465980668.665135, 84, 0.8199999928474426], [
1465980668.697928, 85, 0.8199999928474426
], [1465980668.730525, 86, 0.8799999952316284], [
1465980668.769772, 87, 0.9200000166893005
], [1465980668.803344, 88, 0.8299999833106995], [
1465980668.834414, 89, 0.800000011920929
], [1465980669.814826, 91, 0.8600000143051147], [
1465980669.851511, 92, 0.8899999856948853
], [1465980669.891407, 93, 0.8799999952316284], [
1465980669.927507, 94, 0.9399999976158142
], [1465980669.968384, 95, 0.9300000071525574], [
1465980670.007071, 96, 0.8500000238418579
], [1465980670.044314, 97, 0.8500000238418579], [
1465980670.083472, 98, 0.9100000262260437
], [1465980670.214597, 99, 0.8600000143051147], [
1465980670.934513, 101, 0.8799999952316284
], [1465980670.971317, 102, 0.8700000047683716], [
1465980671.003626, 103, 0.8600000143051147
], [1465980671.037037, 104, 0.8399999737739563], [
1465980671.070037, 105, 0.9200000166893005
], [1465980671.104992, 106, 0.8600000143051147], [
1465980671.137882, 107, 0.8100000023841858
], [1465980671.173917, 108, 0.7400000095367432], [
1465980671.205898, 109, 0.8799999952316284
], [1465980671.833723, 111, 0.9100000262260437]]
def data():
return {
"test": {
"min/layer2/weights": {
"displayName": "min/layer2/weights",
"description": ""
}
},
"train": {
"min/layer2/weights": {
"displayName": "min/layer2/weights",
"description": ""
}
}
}
...@@ -6,9 +6,13 @@ import sys ...@@ -6,9 +6,13 @@ import sys
from optparse import OptionParser from optparse import OptionParser
from flask import Flask, redirect from flask import Flask, redirect
from flask import request
from flask import send_from_directory from flask import send_from_directory
from flask import Response
from visualdl.log import logger from visualdl.log import logger
import visualdl.mock.data as mock_data
import visualdl.mock.tags as mock_tags
app = Flask(__name__, static_url_path="") app = Flask(__name__, static_url_path="")
...@@ -27,14 +31,21 @@ def option_parser(): ...@@ -27,14 +31,21 @@ def option_parser():
action="store", action="store",
dest="port", dest="port",
help="rest api service port") help="rest api service port")
parser.add_option(
"--logdir", action="store", dest="logdir", help="log file directory")
return parser.parse_args() return parser.parse_args()
options, args = option_parser()
server_path = os.path.abspath(os.path.dirname(sys.argv[0]))
static_file_path = "./frontend/dist/"
mock_data_path = "./mock_data/"
# return data # return data
# status, msg, data # status, msg, data
def gen_result(status, msg): def gen_result(status, msg, data):
""" """
:param status: :param status:
:param msg: :param msg:
:return: :return:
...@@ -42,12 +53,13 @@ def gen_result(status, msg): ...@@ -42,12 +53,13 @@ def gen_result(status, msg):
result = dict() result = dict()
result['status'] = status result['status'] = status
result['msg'] = msg result['msg'] = msg
result['data'] = {} result['data'] = data
return result return result
server_path = os.path.abspath(os.path.dirname(sys.argv[0])) @app.route("/")
static_file_path = "../visualdl/frontend/dist/" def index():
return redirect('/static/index.html', code=302)
@app.route('/static/<path:filename>') @app.route('/static/<path:filename>')
...@@ -56,18 +68,35 @@ def serve_static(filename): ...@@ -56,18 +68,35 @@ def serve_static(filename):
os.path.join(server_path, static_file_path), filename) os.path.join(server_path, static_file_path), filename)
@app.route("/") @app.route('/data/logdir')
def index(): def logdir():
return redirect('/static/index.html', code=302) result = gen_result(0, "", {"logdir": options.logdir})
return Response(json.dumps(result), mimetype='application/json')
@app.route('/data/runs')
def runs():
is_debug = bool(request.args.get('debug'))
result = gen_result(0, "", ["train", "test"])
return Response(json.dumps(result), mimetype='application/json')
@app.route("/data/plugin/scalars/tags")
def tags():
is_debug = bool(request.args.get('debug'))
result = gen_result(0, "", mock_tags.data())
return Response(json.dumps(result), mimetype='application/json')
@app.route('/hello') @app.route('/data/plugin/scalars/scalars')
def hello(): def scalars():
result = gen_result(0, "Hello, this is VisualDL!") run = request.args.get('run')
return json.dumps(result) tag = request.args.get('tag')
is_debug = bool(request.args.get('debug'))
result = gen_result(0, "", mock_data.sequence_data())
return Response(json.dumps(result), mimetype='application/json')
if __name__ == '__main__': if __name__ == '__main__':
options, args = option_parser()
logger.info(" port=" + str(options.port)) logger.info(" port=" + str(options.port))
app.run(debug=False, host="0.0.0.0", port=options.port) app.run(debug=False, host="0.0.0.0", port=options.port)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册