diff --git a/frontend/package.json b/frontend/package.json index 57dc9b6da20359fb2ddbfd2f84ed6f48c27b9da0..5cd4c1f81ece93f589a05cda39b66540a62d5990 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", diff --git a/frontend/tool/build.js b/frontend/tool/build.js index d8a67b1f106f82df771200a8c6bb096c441d77cc..2590b88715b1f46b56117fb645f3bbd17c44a720 100644 --- a/frontend/tool/build.js +++ b/frontend/tool/build.js @@ -1,3 +1,4 @@ +"use strict"; const webpack = require('webpack'); const rm = require('rimraf'); const ora = require('ora'); diff --git a/frontend/tool/entry.js b/frontend/tool/entry.js index 78754c6a5dc394ade713c1522657690d9be3b3fc..aba7919bc8050be1642accdd0427192881622aef 100644 --- a/frontend/tool/entry.js +++ b/frontend/tool/entry.js @@ -1,3 +1,4 @@ +"use strict"; const path = require('path'); const projectPath = path.resolve(__dirname, '..'); const HtmlWebpackPlugin = require('html-webpack-plugin'); diff --git a/frontend/tool/webpack.config.js b/frontend/tool/webpack.config.js index 24764208c456bb784655b5934e7c272782abf101..90115251fd425caf901731bc815c64b3426183f3 100644 --- a/frontend/tool/webpack.config.js +++ b/frontend/tool/webpack.config.js @@ -1,3 +1,4 @@ +"use strict"; const webpack = require('webpack'); const path = require('path'); const projectPath = path.resolve(__dirname, '..'); diff --git a/frontend/tool/webpack.prod.config.js b/frontend/tool/webpack.prod.config.js index fa73c7837ef2a7ea12803ba5d6885f01520bbc8b..3d8bbbbcbc06da2c3c2efbc8b9bf0c40593eafa0 100644 --- a/frontend/tool/webpack.prod.config.js +++ b/frontend/tool/webpack.prod.config.js @@ -1,3 +1,4 @@ +"use strict"; const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const path = require('path'); diff --git a/server/visualdl/visual_dl.py b/server/visualdl/visual_dl.py index 79113ada517a9f5b6be7182fa8d2310c96b42d64..955ab0dc80f0c4113a7d8e0cdb6c4da9819cc5a8 100644 --- a/server/visualdl/visual_dl.py +++ b/server/visualdl/visual_dl.py @@ -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) diff --git a/visualdl/logic/im.cc b/visualdl/logic/im.cc index 624fbfbba50fe623cc4226591e336fbb66af9552..3645f530f3de0ab755c7fa359efa5c4d332ab5cb 100644 --- a/visualdl/logic/im.cc +++ b/visualdl/logic/im.cc @@ -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; } diff --git a/visualdl/logic/pybind.cc b/visualdl/logic/pybind.cc index 69d40ca039e606d9d20a3d327347b665c1010480..61ce7fa1bfb844ef5a9080c51355443203de5251 100644 --- a/visualdl/logic/pybind.cc +++ b/visualdl/logic/pybind.cc @@ -41,6 +41,7 @@ PYBIND11_PLUGIN(core) { }); py::class_(m, "Storage") + .def("tags", &vs::StorageHelper::tags) .def("timestamp", &vs::StorageHelper::timestamp) .def("dir", &vs::StorageHelper::dir) .def("set_dir", &vs::StorageHelper::SetDir) diff --git a/visualdl/logic/sdk.h b/visualdl/logic/sdk.h index b74e33174291d31baf44d430116eb86d583c02a6..b5bfc0fe40fc377df8237ba9b29aada63085e23b 100644 --- a/visualdl/logic/sdk.h +++ b/visualdl/logic/sdk.h @@ -82,6 +82,10 @@ public: data_->set_dir(dir); } + std::vector tags() { + return std::vector(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(); } diff --git a/visualdl/python/test_summary.py b/visualdl/python/test_summary.py index d4ce733b68463e54d6adfeaa29501139525b87b5..486035c9713d04490fcb1bd86fb585c571e64cc1 100644 --- a/visualdl/python/test_summary.py +++ b/visualdl/python/test_summary.py @@ -4,8 +4,6 @@ import unittest import random import time -once_flag = False - class ScalarTester(unittest.TestCase): def setUp(self):