diff --git a/visualdl/backend/logic/pybind.cc b/visualdl/backend/logic/pybind.cc index c977963ee03ae702adf3b984ea154c59079daac0..242c25d3e1a80a7704dcfddbaa62775ad1dbde20 100644 --- a/visualdl/backend/logic/pybind.cc +++ b/visualdl/backend/logic/pybind.cc @@ -35,6 +35,7 @@ PYBIND11_MODULE(core, m) { py::class_(m, "Storage") .def("timestamp", &vs::StorageHelper::timestamp) .def("dir", &vs::StorageHelper::dir) + .def("set_dir", &vs::StorageHelper::SetDir) .def("tablets_size", &vs::StorageHelper::tablets_size) .def("buffer", &vs::StorageHelper::buffer) .def("human_readable_buffer", &vs::StorageHelper::human_readable_buffer) diff --git a/visualdl/backend/logic/test.py b/visualdl/backend/logic/test.py deleted file mode 100644 index 3604089892a0b03cdc5289ea683f41fe37ffcb67..0000000000000000000000000000000000000000 --- a/visualdl/backend/logic/test.py +++ /dev/null @@ -1,11 +0,0 @@ -import core - -im = core.im() - -im.add_tablet("tag0", 50) - -tablet = im.tablet("tag0") -tablet.add_scalar_int32(1, 13) - -print "buffer", tablet.buffer() -print "buffer", tablet.human_readable_buffer() diff --git a/visualdl/backend/test.py b/visualdl/backend/test.py new file mode 100644 index 0000000000000000000000000000000000000000..f0cd54d65325c04e3d5f8da19019f8f698329a59 --- /dev/null +++ b/visualdl/backend/test.py @@ -0,0 +1,46 @@ +import sys +import unittest +sys.path.append('../../build') +import core + +im = core.im() + +class StorageTester(unittest.TestCase): + def setUp(self): + self.storage = im.storage() + + def test_size(self): + self.assertEqual(self.storage.tablets_size(), 0) + im.add_tablet("tag0", 100) + self.assertEqual(self.storage.tablets_size(), 1) + + for i in range(1, 11): + im.add_tablet("tag%d" % i, 100) + self.assertEqual(self.storage.tablets_size(), 11) + + def test_timestamp(self): + print self.storage.timestamp() + + def test_dir(self): + dir = "./1.txt" + self.storage.set_dir(dir) + self.assertEqual(dir, self.storage.dir()) + + def test_human_readable_buffer(self): + print self.storage.human_readable_buffer() + + +class TabletTester(unittest.TestCase): + def setUp(self): + self.tablet = im.add_tablet("tag101", 20) + + def test_add_scalar(self): + self.tablet.add_scalar_float(1, 0.3) + self.assertEqual(self.tablet.records_size(), 1) + + def test_human_readable_buffer(self): + print self.tablet.human_readable_buffer() + + +if __name__ == '__main__': + unittest.main()