提交 b632c19f 编写于 作者: S superjom

image service ready

fix most bugs

waiting for frontend to fix interfaces
上级 401e139b
......@@ -21,6 +21,18 @@ def get_scalar_tags(storage, mode):
return result
def get_scalar(storage, mode, tag):
reader = storage.as_mode(mode)
scalar = reader.scalar(tag)
records = scalar.records()
ids = scalar.ids()
timestamps = scalar.timestamps()
result = zip(timestamps, ids, records)
return result
def get_image_tags(storage, mode):
result = {}
......@@ -31,16 +43,17 @@ def get_image_tags(storage, mode):
result[mode] = {}
for tag in reader.tags('image'):
image = reader.image(tag)
if image.num_samples() == 1:
if image.num_samples() <= 1:
result[mode][tag] = {
'displayName': mage.caption(),
'displayName': image.caption(),
'description': "",
'samples': 1,
}
else:
for i in xrange(image.num_samples()):
result[mode][tag + '/%d' % i] = {
'displayName': image.caption(),
caption = tag + '/%d' % i
result[mode][caption] = {
'displayName': caption,
'description': "",
'samples': 1,
}
......@@ -51,6 +64,7 @@ def get_image_tag_steps(storage, mode, tag):
# remove suffix '/x'
res = re.search(r".*/([0-9]+$)", tag)
step_index = 0
origin_tag = tag
if res:
tag = tag[:tag.rfind('/')]
step_index = int(res.groups()[0])
......@@ -65,7 +79,7 @@ def get_image_tag_steps(storage, mode, tag):
query = urllib.urlencode({
'sample': 0,
'index': i,
'tag': tag,
'tag': origin_tag,
'run': mode,
})
res.append({
......
......@@ -2,5 +2,7 @@
set -ex
export PYTHONPATH="$(pwd)/..:/home/superjom/project/VisualDL/build/visualdl/logic:/home/superjom/project/VisualDL/visualdl/python"
export FLASK_APP=visual_dl.py
export FLASK_DEBUG=1
python visual_dl.py --logdir ./tmp/mock --host 172.23.233.68
python visual_dl.py --logdir ./tmp/mock --host 172.23.233.68 --port 8041
......@@ -95,7 +95,8 @@ def runs():
@app.route("/data/plugin/scalars/tags")
def tags():
def scalar_tags():
mode = request.args.get('mode')
is_debug = bool(request.args.get('debug'))
if is_debug:
result = mock_tags.data()
......@@ -107,7 +108,8 @@ def tags():
@app.route("/data/plugin/images/tags")
def tags():
def image_tags():
mode = request.args.get('mode')
result = lib.get_image_tags(storage, mode)
print 'tags', result
result = gen_result(0, "", result)
......@@ -120,39 +122,33 @@ def scalars():
tag = request.args.get('tag')
is_debug = bool(request.args.get('debug'))
if is_debug:
result = gen_result(0, "", mock_data.sequence_data())
result = mock_data.sequence_data()
else:
reader = storage.as_mode(run)
scalar = reader.scalar(tag)
records = scalar.records()
ids = scalar.ids()
timestamps = scalar.timestamps()
result = zip(timestamps, ids, records)
result = gen_result(0, "", result)
result = lib.get_scalar(storage, run, tag)
result = gen_result(0, "", result)
return Response(json.dumps(result), mimetype='application/json')
@app.route('/data/plugin/images/images')
def images():
run = request.args.get('run')
tag = request.args.get('tag')
mode = request.args.get('run')
#tag = request.args.get('tag')
tag = request.args.get('displayName')
res = lib.gen_image_tag_steps(storage, mode, tag)
result = lib.get_image_tag_steps(storage, mode, tag)
return Response(json.dumps(result), mimetype='application/json')
@app.route('/data/plugin/images/individualImage')
def individual_image():
run = request.args.get('run')
mode = request.args.get('run')
tag = request.args.get('tag') # include a index
index = request.args.get('index') # index of step
step_index = request.args.get('index') # index of step
offset = 0
imagefile = lib.get_invididual_image(storage, mode, tag)
imagefile = lib.get_invididual_image(storage, mode, tag, step_)
response = send_file(
imagefile, as_attachment=True, attachment_filename='img.png')
return response
......@@ -160,4 +156,4 @@ def individual_image():
if __name__ == '__main__':
logger.info(" port=" + str(options.port))
app.run(debug=False, host=options.host, port=options.port)
app.run(debug=True, host=options.host, port=options.port)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册