diff --git a/CMakeLists.txt b/CMakeLists.txt index 025f6989433092e91cef0ee117b496a7be83580b..590abdd68547a2612b5d0a6e184618f4ff29dc6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,4 +49,3 @@ enable_testing () add_custom_target(test_init COMMAND $CMAKE_BINARY_DIR) add_test(NAME vstest COMMAND ./vl_test) -set_target_properties(vl_test PROPERTIES DEPENDS test_init) diff --git a/tests.sh b/tests.sh deleted file mode 100644 index 7e51cb30e28d1597a5aa70db7fb64e3e46f6b3b9..0000000000000000000000000000000000000000 --- a/tests.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -ex - -sudo pip install numpy -#sudo apt-get install --only-upgrade cmake -y -mkdir -p build -cd build -cmake .. -make -make test - -#if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./travis/run_on_pull_requests; fi -#if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./travis/run_on_non_pull_requests; fi diff --git a/visualdl/logic/im.cc b/visualdl/logic/im.cc index f8fe192456c27a201525f807abe9e73bdcf55487..a2ec1f22e23b260385e887e3c40a91328ce112b9 100644 --- a/visualdl/logic/im.cc +++ b/visualdl/logic/im.cc @@ -32,5 +32,11 @@ void SimpleWriteSyncGuard::Sync() { template class SimpleWriteSyncGuard; template class SimpleWriteSyncGuard; template class SimpleWriteSyncGuard; +template class SimpleWriteSyncGuard>; +template class SimpleWriteSyncGuard>; +template class SimpleWriteSyncGuard>; +template class SimpleWriteSyncGuard>; +template class SimpleWriteSyncGuard>; +template class SimpleWriteSyncGuard>; } // namespace visualdl diff --git a/visualdl/logic/pybind.cc b/visualdl/logic/pybind.cc index 7503ed74838a347cf037a2f1763f3aa2e16ca8cd..de82b415e375924f349e0cf5a869776374491d62 100644 --- a/visualdl/logic/pybind.cc +++ b/visualdl/logic/pybind.cc @@ -15,6 +15,7 @@ PYBIND11_PLUGIN(core) { py::class_>(m, "ScalarReader__" #T) \ .def("records", &cp::ScalarReader::records) \ .def("timestamps", &cp::ScalarReader::timestamps) \ + .def("ids", &cp::ScalarReader::ids) \ .def("caption", &cp::ScalarReader::caption); ADD_SCALAR(int); ADD_SCALAR(float); @@ -57,9 +58,7 @@ PYBIND11_PLUGIN(core) { py::class_(m, "Writer") .def("__init__", - [](vs::Writer& instance, - const std::string& dir, - int sync_cycle) { + [](vs::Writer& instance, const std::string& dir, int sync_cycle) { new (&instance) vs::Writer(dir); instance.storage().meta.cycle = sync_cycle; }) diff --git a/visualdl/logic/sdk.cc b/visualdl/logic/sdk.cc index 7f94ceef69d41c1888b91ab6cd9241e4e5e8f047..62c46ea6d71d34c94e88d9f019bdfd5ef73c3591 100644 --- a/visualdl/logic/sdk.cc +++ b/visualdl/logic/sdk.cc @@ -4,61 +4,48 @@ namespace visualdl { namespace components { -// template -// void components::Scalar::AddRecord(int id, const std::vector &values) { -// // add record data -// auto record = tablet_.AddRecord(); -// auto entry = record.AddData(); -// for (auto v : values) { -// entry.Add(v); -// } -// // set record id -// record.SetId(id); -// // set record timestamp -// record.SetTimeStamp(time(NULL)); -// } - -// template -// std::vector ScalarReader::records() const { -// std::vector res; -// for (int i = 0; i < reader_.total_records(); i++) { -// res.push_back(reader_.record(i).data(0)); -// } -// return res; -// } - -// template -// std::vector ScalarReader::ids() const { -// std::vector res; -// for (int i = 0; i < reader_.total_records(); i++) { -// res.push_back(reader_.record(i).id()); -// } -// return res; -// } - -// template -// std::vector ScalarReader::timestamps() const { -// std::vector res; -// for (int i = 0; i < reader_.total_records(); i++) { -// res.push_back(reader_.record(i).timestamp()); -// } -// return res; -// } - -// template -// std::vector ScalarReader::captions() const { -// return reader_.captions(); -// } - -// template -// size_t ScalarReader::size() const { -// return reader_.total_records(); -// } - -// template class Scalar; -// template class Scalar; -// template class Scalar; -// template class Scalar; +template +std::vector ScalarReader::records() const { + std::vector res; + for (int i = 0; i < reader_.total_records(); i++) { + res.push_back(reader_.record(i).data(0).Get()); + } + return res; +} + +template +std::vector ScalarReader::ids() const { + std::vector res; + for (int i = 0; i < reader_.total_records(); i++) { + res.push_back(reader_.record(i).id()); + } + return res; +} + +template +std::vector ScalarReader::timestamps() const { + std::vector res; + for (int i = 0; i < reader_.total_records(); i++) { + res.push_back(reader_.record(i).timestamp()); + } + return res; +} + +template +std::string ScalarReader::caption() const { + CHECK(!reader_.captions().empty()) << "no caption"; + return reader_.captions().front(); +} + +template +size_t ScalarReader::size() const { + return reader_.total_records(); +} + +template class ScalarReader; +template class ScalarReader; +template class ScalarReader; +template class ScalarReader; } // namespace components diff --git a/visualdl/logic/sdk.h b/visualdl/logic/sdk.h index 0c7525d8a33a578754c9f6bcedf4f7a145a323a8..96ee4321623923a2b55668cda89f863514381db0 100644 --- a/visualdl/logic/sdk.h +++ b/visualdl/logic/sdk.h @@ -91,43 +91,6 @@ private: TabletReader reader_; }; -template -std::vector ScalarReader::records() const { - std::vector res; - for (int i = 0; i < reader_.total_records(); i++) { - res.push_back(reader_.record(i).data(0).Get()); - } - return res; -} - -template -std::vector ScalarReader::ids() const { - std::vector res; - for (int i = 0; i < reader_.total_records(); i++) { - res.push_back(reader_.record(i).id()); - } - return res; -} - -template -std::vector ScalarReader::timestamps() const { - std::vector res; - for (int i = 0; i < reader_.total_records(); i++) { - res.push_back(reader_.record(i).timestamp()); - } - return res; -} - -template -std::string ScalarReader::caption() const { - CHECK(!reader_.captions().empty()) << "no caption"; - return reader_.captions().front(); -} - -template -size_t ScalarReader::size() const { - return reader_.total_records(); -} } // namespace components } // namespace visualdl diff --git a/visualdl/python/CMakeLists.txt b/visualdl/python/CMakeLists.txt index def51de942894def455976795445e078ea6fb2d8..2f37afb567abdd5930eeb1ebb4fe278beff741e9 100644 --- a/visualdl/python/CMakeLists.txt +++ b/visualdl/python/CMakeLists.txt @@ -10,4 +10,4 @@ function(py_test TARGET_NAME) ) endfunction() -py_test(test_summary SRCS test_summary.py) +py_test(test_summary SRCS test_storage.py) diff --git a/visualdl/python/test_summary.py b/visualdl/python/test_storage.py similarity index 68% rename from visualdl/python/test_summary.py rename to visualdl/python/test_storage.py index 460e05a35603b0a3a996b820aecf9de72441928d..ef5914990e5cb3c8ae1ea4d18e2bffa6f39c8b89 100644 --- a/visualdl/python/test_summary.py +++ b/visualdl/python/test_storage.py @@ -14,12 +14,18 @@ class StorageTest(unittest.TestCase): scalar = self.writer.scalar("model/scalar/min") # scalar.set_caption("model/scalar/min") for i in range(10): - scalar.add_record(i, 1.0) + scalar.add_record(i, float(i)) print 'test read' self.reader = storage.StorageReader("train", self.dir) scalar = self.reader.scalar("model/scalar/min") self.assertEqual(scalar.caption(), "train") + records = scalar.records() + ids = scalar.ids() + self.assertTrue(np.equal(records, [float(i) for i in range(10)]).all()) + self.assertTrue(np.equal(ids, [float(i) for i in range(10)]).all()) + print 'records', records + print 'ids', ids if __name__ == '__main__': diff --git a/visualdl/storage/CMakeLists.txt b/visualdl/storage/CMakeLists.txt index 3a0b36caca84e6a446269d27d65ea07260aa79fb..ec9dfbbf8f464a0d55670452d0a429d720b2e31f 100644 --- a/visualdl/storage/CMakeLists.txt +++ b/visualdl/storage/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(tablet tablet.cc tablet.h ${PROTO_SRCS} ${PROTO_HDRS}) add_library(record record.cc record.h ${PROTO_SRCS} ${PROTO_HDRS}) add_library(storage storage.cc storage.h ${PROTO_SRCS} ${PROTO_HDRS}) -add_dependencies(entry storage_proto) +add_dependencies(entry storage_proto im) add_dependencies(record storage_proto entry) add_dependencies(tablet storage_proto) add_dependencies(storage storage_proto) diff --git a/visualdl/storage/entry.cc b/visualdl/storage/entry.cc index 71e118842a0a19e167410a8701b4a45fca085a5c..0d4fc8dd3b0e081ed171e3f5fb9699509fdd5d36 100644 --- a/visualdl/storage/entry.cc +++ b/visualdl/storage/entry.cc @@ -7,6 +7,7 @@ namespace visualdl { void Entry::method__(ctype__ v) { \ entry->set_dtype(storage::DataType::dtype__); \ entry->opr__(v); \ + WRITE_GUARD \ } IMPL_ENTRY_SET_OR_ADD(Set, int, kInt32, set_i32); @@ -57,5 +58,4 @@ template class EntryReader; template class EntryReader; template class EntryReader; - } // namespace visualdl diff --git a/visualdl/storage/entry.h b/visualdl/storage/entry.h index 6516efb3045e17e7203af8ac67d3d5a9d3b5534b..060b03827b8bdfd9cfe278c52c31f753e939d28c 100644 --- a/visualdl/storage/entry.h +++ b/visualdl/storage/entry.h @@ -14,7 +14,7 @@ struct Storage; */ template struct Entry { - DECL_GUARD(Entry) + DECL_GUARD(Entry) // use pointer to avoid copy storage::Entry* entry{nullptr};