Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 7ffe276

Browse files
gshimanskyalexbaden
authored andcommitted
Fixed finding root path when HDK is installed in conda env and is called from python.
Signed-off-by: Gregory Shimansky <[email protected]>
1 parent fddc7ce commit 7ffe276

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

omniscidb/OSDependent/Windows/omnisci_path.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "OSDependent/omnisci_path.h"
1818

1919
#include <boost/filesystem/path.hpp>
20+
#include <filesystem>
2021

2122
#include "Logger/Logger.h"
2223

@@ -31,10 +32,23 @@ std::string get_root_abs_path() {
3132
CHECK_LT(static_cast<size_t>(path_len), sizeof(abs_exe_path));
3233
boost::filesystem::path abs_exe_dir(std::string(abs_exe_path, path_len));
3334
abs_exe_dir.remove_filename();
34-
// account for build type dir (e.g. Release)
35-
const auto mapd_root = abs_exe_dir.parent_path().parent_path();
36-
37-
return mapd_root.string();
35+
// When installed in conda env the path points python.exe that is located
36+
// in the root of conda environment.
37+
// When running tests in built repo the path points to omniscidb\Tests\{Debug|Release}\
38+
// which is three levels below "bin" directory with calcite jar file.
39+
// Because of this disbalance we try to look up QueryEngine/RuntimeFunctions.bc file.
40+
// QueryEngine is located either one level below "bin" or on the same level. When it is
41+
// below "bin" then this one more up level is done in CalciteJNI.
42+
const int UP_PATH_LEVELS = 2;
43+
for (int up_levels = 0; up_levels <= UP_PATH_LEVELS; up_levels++) {
44+
std::string target_path = abs_exe_dir.string() + "/QueryEngine/RuntimeFunctions.bc";
45+
if (std::filesystem::exists(target_path)) {
46+
break;
47+
}
48+
abs_exe_dir = abs_exe_dir.parent_path();
49+
}
50+
51+
return abs_exe_dir.string();
3852
}
3953

4054
} // namespace omnisci

0 commit comments

Comments
 (0)