提交 702b844d 编写于 作者: S superjom

debug

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