Skip to content

Commit 6759ca1

Browse files
authored
Expose build_config() in Python (#388)
1 parent c81fe46 commit 6759ca1

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

apis/python/src/tiledb/vector_search/type_erased_module.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "api/ivf_flat_index.h"
4343
#include "api/vamana_index.h"
4444
#include "detail/time/temporal_policy.h"
45+
#include "stats.h"
4546

4647
namespace py = pybind11;
4748

@@ -440,4 +441,6 @@ void init_type_erased_module(py::module_& m) {
440441
.def("id_type_string", &IndexIVFFlat::id_type_string)
441442
.def("px_type_string", &IndexIVFFlat::px_type_string)
442443
.def("dimensions", &IndexIVFFlat::dimensions);
444+
445+
m.def("build_config_string", []() { return build_config().dump(); });
443446
}

src/include/stats.h

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -222,42 +222,20 @@ static auto dump_logs = [](std::string filename,
222222
}
223223
};
224224

225-
#ifdef JSON_LOGGING
226-
static auto config_log(const std::string& program_name) {
227-
std::string uuid_;
228-
char host_[16];
229-
std::string date_;
230-
std::size_t uuid_size_ = 24;
231-
232-
auto seed = std::random_device();
233-
auto gen = std::mt19937(seed());
234-
auto dis = std::uniform_int_distribution<int8_t>(97, 122);
235-
uuid_.resize(uuid_size_);
236-
std::generate(uuid_.begin(), uuid_.end(), [&] { return dis(gen); });
237-
238-
if (int e = gethostname(host_, sizeof(host_))) {
239-
std::cerr << "truncated host name\n";
240-
strncpy(host_, "ghost", 15);
241-
}
242-
{
243-
std::stringstream ss;
244-
std::time_t currentTime = std::time(nullptr);
245-
std::string dateString = std::ctime(&currentTime);
246-
dateString.erase(dateString.find('\n'));
247-
ss << dateString;
248-
date_ = ss.str();
249-
}
225+
static auto build_config() {
226+
// This is failing today, but could perhaps be added back in the future.
227+
// char host_[16];
228+
// if (int e = gethostname(host_, sizeof(host_))) {
229+
// std::cerr << "truncated host name\n";
230+
// strncpy(host_, "ghost", 15);
231+
// }
250232

251233
auto&& [major, minor, patch] = tiledb::version();
252234

253235
json config = {
254-
{"uuid", uuid_},
255-
{"host", host_},
256-
{"Program", program_name},
257-
{"Build_date", CURRENT_DATETIME},
258-
{"Run_date", date_},
259-
{"cmake_source_dir", CMAKE_SOURCE_DIR},
260-
{"Build", BUILD_TYPE},
236+
{"CURRENT_DATETIME", CURRENT_DATETIME},
237+
{"CMAKE_SOURCE_DIR", CMAKE_SOURCE_DIR},
238+
{"BUILD_TYPE", BUILD_TYPE},
261239
{"Compiler",
262240
{{"CXX_COMPILER", IVF_HACK_CXX_COMPILER},
263241
{"CXX_COMPILER_ID", CXX_COMPILER_ID},
@@ -296,6 +274,5 @@ auto args_log(const Args& args) {
296274
}
297275
return arg_log;
298276
}
299-
#endif // JSON_LOGGING
300277

301278
#endif // TDB_STATS_H

src/include/test/unit_stats.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@
2727
*
2828
* @section DESCRIPTION
2929
*
30-
* WIP.
3130
*/
3231

3332
#include <catch2/catch_all.hpp>
34-
#include <chrono>
35-
#include <iostream>
36-
#include <thread>
3733

38-
#include "utils/logging.h"
39-
#include "utils/timer.h"
34+
#include "stats.h"
4035

4136
TEST_CASE("stats: test test", "[stats]") {
4237
REQUIRE(true);
4338
}
39+
40+
TEST_CASE("stats: test build_config", "[stats]") {
41+
build_config();
42+
}

0 commit comments

Comments
 (0)