提交 0c98a55f 编写于 作者: S superjom

debug

上级 ce452e3e
......@@ -8,9 +8,7 @@
"release": "cross-env NODE_ENV=production node ./tool/build.js",
"build": "cross-env NODE_ENV=dev node ./tool/build.js",
"dev": "cross-env NODE_ENV=dev node tool/dev-server.js",
"lint": "./node_modules/fecs/bin/fecs --rule",
"precommit": "npm run lint",
"prepush": "npm run lint"
"lint": "./node_modules/fecs/bin/fecs --rule"
},
"engines": {
"node": ">= 6.4.0"
......@@ -54,7 +52,6 @@
"html-loader": "^0.4.4",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.4",
"husky": "^0.14.3",
"json-loader": "^0.5.4",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^1.3.2",
......
"use strict";
const webpack = require('webpack');
const rm = require('rimraf');
const ora = require('ora');
......
"use strict";
const path = require('path');
const projectPath = path.resolve(__dirname, '..');
const HtmlWebpackPlugin = require('html-webpack-plugin');
......
"use strict";
const webpack = require('webpack');
const path = require('path');
const projectPath = path.resolve(__dirname, '..');
......
"use strict";
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
......
......@@ -13,6 +13,7 @@ from flask import Response
from visualdl.log import logger
import visualdl.mock.data as mock_data
import visualdl.mock.tags as mock_tags
import summary
app = Flask(__name__, static_url_path="")
......@@ -31,7 +32,14 @@ def option_parser():
default=8040,
action="store",
dest="port",
help="rest api service port")
help="api service port")
parser.add_option(
"-t",
"--host",
type=str,
default="0.0.0.0",
action="store",
help="api service ip")
parser.add_option(
"--logdir", action="store", dest="logdir", help="log file directory")
return parser.parse_args()
......@@ -42,6 +50,8 @@ server_path = os.path.abspath(os.path.dirname(sys.argv[0]))
static_file_path = "./frontend/dist/"
mock_data_path = "./mock_data/"
im = summary.IM('./tmp', 'read', 500)
# return data
# status, msg, data
......@@ -85,7 +95,15 @@ def runs():
@app.route("/data/plugin/scalars/tags")
def tags():
is_debug = bool(request.args.get('debug'))
result = gen_result(0, "", mock_tags.data())
tag = request.args.get('tag')
# NOTE debug
is_debug = True
if is_debug:
result = mock_tags.data()
else:
result = im.storage().tags()
print 'tags', result
result = gen_result(0, "", result)
return Response(json.dumps(result), mimetype='application/json')
......@@ -93,11 +111,30 @@ def tags():
def scalars():
run = request.args.get('run')
tag = request.args.get('tag')
# NOTE debug
tag = "tag0"
is_debug = bool(request.args.get('debug'))
result = gen_result(0, "", mock_data.sequence_data())
if is_debug:
result = gen_result(0, "", mock_data.sequence_data())
else:
scalar = summary.scalar(im, tag)
result = []
for id, tag in enumerate(scalar.captions):
records = [v[id] for v in scalar.records]
line = [
a
for a in zip([float(a)
for a in scalar.timestamps], scalar.ids, records)
]
result.append(line)
result = result[0]
result = gen_result(0, "", result)
return Response(json.dumps(result), mimetype='application/json')
if __name__ == '__main__':
logger.info(" port=" + str(options.port))
app.run(debug=False, host="0.0.0.0", port=options.port)
app.run(debug=False, host=options.host, port=options.port)
......@@ -32,6 +32,7 @@ void IM::SetPersistDest(const std::string &path) {
}
storage::Tablet *IM::AddTablet(const std::string &tag, int num_samples) {
CHECK(!tag.empty()) << "invalid tag name '" << tag << "'";
auto tablet = storage_->NewTablet(tag, num_samples);
return tablet;
}
......
......@@ -41,6 +41,7 @@ PYBIND11_PLUGIN(core) {
});
py::class_<vs::StorageHelper>(m, "Storage")
.def("tags", &vs::StorageHelper::tags)
.def("timestamp", &vs::StorageHelper::timestamp)
.def("dir", &vs::StorageHelper::dir)
.def("set_dir", &vs::StorageHelper::SetDir)
......
......@@ -82,6 +82,10 @@ public:
data_->set_dir(dir);
}
std::vector<std::string> tags() {
return std::vector<std::string>(data_->tags().begin(), data_->tags().end());
}
int64_t timestamp() const { return data_->timestamp(); }
std::string dir() const { return data_->dir(); }
int tablets_size() const { return data_->tablets_size(); }
......
......@@ -4,8 +4,6 @@ import unittest
import random
import time
once_flag = False
class ScalarTester(unittest.TestCase):
def setUp(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册