未验证 提交 30fdbc6b 编写于 作者: J Jeff Wang 提交者: GitHub

Add manual Save feature. (#332)

* Add manual Save feature.

* Fix the incorrect style
上级 2267c4e8
......@@ -86,6 +86,7 @@ PYBIND11_MODULE(core, m) {
}))
.def("set_mode", &vs::LogWriter::SetMode)
.def("as_mode", &vs::LogWriter::AsMode)
.def("save", &vs::LogWriter::Save)
// clang-format off
#define WRITER_ADD_SCALAR(T) \
.def("new_scalar_" #T, [](vs::LogWriter& self, const std::string& tag) { \
......@@ -127,10 +128,15 @@ PYBIND11_MODULE(core, m) {
ADD_SCALAR_READER(int64_t);
#undef ADD_SCALAR_READER
#define ADD_SCALAR_WRITER(T) \
py::class_<cp::Scalar<T>>(m, "ScalarWriter__" #T, R"pbdoc(PyBind class. Must instantiate through the LogWriter.)pbdoc") \
.def("set_caption", &cp::Scalar<T>::SetCaption) \
.def("add_record", &cp::Scalar<T>::AddRecord, R"pbdoc(add a record with the step and value)pbdoc");
#define ADD_SCALAR_WRITER(T) \
py::class_<cp::Scalar<T>>( \
m, \
"ScalarWriter__" #T, \
R"pbdoc(PyBind class. Must instantiate through the LogWriter.)pbdoc") \
.def("set_caption", &cp::Scalar<T>::SetCaption) \
.def("add_record", \
&cp::Scalar<T>::AddRecord, \
R"pbdoc(add a record with the step and value)pbdoc");
ADD_SCALAR_WRITER(int);
ADD_SCALAR_WRITER(float);
ADD_SCALAR_WRITER(double);
......@@ -192,9 +198,12 @@ PYBIND11_MODULE(core, m) {
.def("record", &cp::ImageReader::record)
.def("timestamp", &cp::ImageReader::timestamp);
#define ADD_HISTOGRAM_WRITER(T) \
py::class_<cp::Histogram<T>>(m, "HistogramWriter__" #T, R"pbdoc(PyBind class. Must instantiate through the LogWriter.)pbdoc") \
.def("add_record", &cp::Histogram<T>::AddRecord, R"pbdoc(add a record with the step and histogram_value)pbdoc");
#define ADD_HISTOGRAM_WRITER(T) \
py::class_<cp::Histogram<T>>(m, "HistogramWriter__" #T, \
R"pbdoc(PyBind class. Must instantiate through the LogWriter.)pbdoc") \
.def("add_record", \
&cp::Histogram<T>::AddRecord, \
R"pbdoc(add a record with the step and histogram_value)pbdoc");
ADD_FULL_TYPE_IMPL(ADD_HISTOGRAM_WRITER)
#undef ADD_HISTOGRAM_WRITER
......
......@@ -44,7 +44,7 @@ public:
mode_ = mode;
storage_.AddMode(mode);
}
void Save() { storage_.PersistToDisk(); }
LogWriter AsMode(const std::string& mode);
Tablet AddTablet(const std::string& tag);
......
......@@ -222,6 +222,9 @@ class LogWriter(object):
}
return types[type](tag, num_buckets)
def save(self):
self.writer.save()
def __enter__(self):
return self
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册