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

Add API to enable debug timers in PyHDK. #33

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion omniscidb
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(pydeps
${PXD_SOURCES}
Calcite)

set(SETUP_LDFLAGS "-L$<TARGET_FILE_DIR:Calcite> -L$<TARGET_FILE_DIR:ArrowStorage> -L$<TARGET_FILE_DIR:QueryEngine> -L$<TARGET_FILE_DIR:SchemaMgr> -L$<TARGET_FILE_DIR:Shared> -L$<TARGET_FILE_DIR:DataMgr>")
set(SETUP_LDFLAGS "-L$<TARGET_FILE_DIR:Calcite> -L$<TARGET_FILE_DIR:ArrowStorage> -L$<TARGET_FILE_DIR:QueryEngine> -L$<TARGET_FILE_DIR:SchemaMgr> -L$<TARGET_FILE_DIR:Logger> -L$<TARGET_FILE_DIR:Shared> -L$<TARGET_FILE_DIR:DataMgr>")
set(SETUP_FLAGS -g -f -I ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(pyhdk ALL
COMMAND cd ${CMAKE_CURRENT_BINARY_DIR} && LDFLAGS=${SETUP_LDFLAGS} ${Python3_EXECUTABLE} ${SETUP_PY} build_ext ${SETUP_FLAGS}
Expand Down
2 changes: 1 addition & 1 deletion python/pyhdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
prev = sys.getdlopenflags()
sys.setdlopenflags(os.RTLD_LAZY | os.RTLD_GLOBAL)

from pyhdk._common import TypeInfo, SQLType, setGlobalConfig
from pyhdk._common import TypeInfo, SQLType, setGlobalConfig, initLogger
from pyhdk._execute import Executor
import pyhdk.sql as sql
import pyhdk.storage as storage
Expand Down
7 changes: 7 additions & 0 deletions python/pyhdk/_common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,10 @@ cdef extern from "omniscidb/ThriftHandler/CommandLineOptions.h":
cdef bool g_null_div_by_zero
cdef bool g_enable_watchdog
cdef bool g_enable_dynamic_watchdog
cdef bool g_enable_debug_timer

cdef extern from "omniscidb/Logger/Logger.h" namespace "logger":
cdef cppclass CLogOptions "logger::LogOptions":
CLogOptions(const char*)

cdef void CInitLogger "logger::init"(const CLogOptions &)
14 changes: 13 additions & 1 deletion python/pyhdk/_common.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from libcpp.memory cimport unique_ptr, make_unique
from cython.operator cimport dereference

cdef class SQLType:
cdef CSQLTypes c_val

Expand Down Expand Up @@ -113,10 +116,19 @@ cdef class TypeInfo:
def __repr__(self):
return self.c_type_info.toString()

def setGlobalConfig(*, enable_union=None, null_div_by_zero=None, **kwargs):
def setGlobalConfig(*, enable_union=None, null_div_by_zero=None, enable_debug_timer=None, **kwargs):
global g_enable_union
global g_null_div_by_zero
global g_enable_debug_timer
if enable_union is not None:
g_enable_union = enable_union
if null_div_by_zero is not None:
g_null_div_by_zero = null_div_by_zero
if enable_debug_timer is not None:
g_enable_debug_timer = enable_debug_timer

def initLogger(*, **kwargs):
argv0 = "PyHDK".encode('UTF-8')
cdef char *cargv0 = argv0
cdef unique_ptr[CLogOptions] opts = make_unique[CLogOptions](cargv0)
CInitLogger(dereference(opts))
4 changes: 2 additions & 2 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ include_dirs = [
"@CMAKE_SOURCE_DIR@/omniscidb",
"@CMAKE_SOURCE_DIR@/omniscidb/ThirdParty",
"@CMAKE_SOURCE_DIR@/omniscidb/ThirdParty/rapidjson",
"@LLVM_INCLUDE_DIRS@"
"@LLVM_INCLUDE_DIRS@",
]

common = Extension(
Expand All @@ -48,7 +48,7 @@ common = Extension(
include_dirs=include_dirs,
library_dirs=pa.get_library_dirs() + ["@CMAKE_CURRENT_BINARY_DIR@", "."],
runtime_library_dirs=pa.get_library_dirs(),
libraries=pa.get_libraries() + ["QueryEngine", "Shared"],
libraries=pa.get_libraries() + ["QueryEngine", "Logger", "Shared"],
extra_compile_args=["-std=c++17"],
)

Expand Down