Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for a stable 1.0.0 release #246

Merged
merged 12 commits into from
Jan 12, 2021
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ addons:
homebrew:
packages:
- cmake
- gcc@7
- libomp
- wget
- lcov
Expand Down
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set (CMAKE_FIND_NO_INSTALL_PREFIX TRUE FORCE)
cmake_minimum_required (VERSION 3.14)
cmake_minimum_required (VERSION 3.13)
project(treelite LANGUAGES CXX C VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 14)
Expand All @@ -14,6 +14,7 @@ endif()
option(TEST_COVERAGE "C++ test coverage" OFF)
option(USE_OPENMP "Use OpenMP" ON)
option(BUILD_CPP_TEST "Build C++ tests" OFF)
option(BUILD_STATIC_LIBS "Build static libs, in addition to dynamic libs" OFF)
option(DETECT_CONDA_ENV "Enable detection of conda environment for dependencies" ON)
option(BUILD_JVM_RUNTIME "Build Treelite runtime for JVM" OFF)
option(ENABLE_ALL_WARNINGS "Enable all compiler warnings. Only effective for GCC/Clang" OFF)
Expand Down Expand Up @@ -51,23 +52,29 @@ if(BUILD_CPP_TEST)
endif()

add_library(treelite SHARED)
add_library(treelite_static STATIC)
add_library(treelite_runtime SHARED)
add_library(treelite_runtime_static STATIC)
target_link_libraries(treelite PRIVATE objtreelite objtreelite_common)
target_link_libraries(treelite_static PRIVATE objtreelite objtreelite_common)
target_link_libraries(treelite_runtime PRIVATE objtreelite_runtime objtreelite_common)
target_link_libraries(treelite_runtime_static PRIVATE objtreelite_runtime objtreelite_common)

foreach(lib treelite treelite_static treelite_runtime treelite_runtime_static)
set(TREELITE_TARGETS treelite treelite_runtime)

if(BUILD_STATIC_LIBS)
add_library(treelite_static STATIC)
add_library(treelite_runtime_static STATIC)
target_link_libraries(treelite_static PRIVATE objtreelite objtreelite_common)
target_link_libraries(treelite_runtime_static PRIVATE objtreelite_runtime objtreelite_common)
list(APPEND TREELITE_TARGETS treelite_static treelite_runtime_static)
endif()

foreach(lib ${TREELITE_TARGETS})
set_output_directory(${lib} ${PROJECT_BINARY_DIR})
target_link_libraries(${lib} INTERFACE dmlc)
endforeach()

# Export install targets
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(INSTALL_TARGETS treelite treelite_static treelite_runtime treelite_runtime_static
set(INSTALL_TARGETS ${TREELITE_TARGETS}
objtreelite objtreelite_common objtreelite_runtime dmlc rapidjson)
if(NOT FMTLIB_FROM_SYSTEM_ROOT)
list(APPEND INSTALL_TARGETS fmt-header-only)
Expand Down
3 changes: 2 additions & 1 deletion cmake/ExternalLibs.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
include(FetchContent)
include(cmake/FetchContentMakeAvailable.cmake)

FetchContent_Declare(
dmlccore
GIT_REPOSITORY https://github.com/dmlc/dmlc-core
GIT_TAG v0.4
GIT_TAG f0ff3146705e27ac2b1e6081fa0983a8a6fda72d
)
FetchContent_MakeAvailable(dmlccore)
target_compile_options(dmlc PRIVATE
Expand Down
10 changes: 10 additions & 0 deletions cmake/FetchContentMakeAvailable.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Credit: https://github.com/ademuri/cmake-fetch-content
if(${CMAKE_VERSION} VERSION_LESS 3.14)
macro(FetchContent_MakeAvailable NAME)
FetchContent_GetProperties(${NAME})
if(NOT ${NAME}_POPULATED)
FetchContent_Populate(${NAME})
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
endif()
endmacro()
endif()
4 changes: 4 additions & 0 deletions python/treelite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import absolute_import as _abs

import sys
import os
import ctypes

from .util import py_str, _log_callback, TreeliteError
Expand All @@ -12,6 +13,9 @@
def _load_lib():
"""Load Treelite Library."""
lib_path = find_lib_path()
if sys.version_info >= (3, 8) and sys.platform == 'win32':
# pylint: disable=no-member
os.add_dll_directory(os.path.join(os.path.normpath(sys.prefix), 'Library', 'bin'))
lib = ctypes.cdll.LoadLibrary(lib_path[0])
lib.TreeliteGetLastError.restype = ctypes.c_char_p
lib.callback = _log_callback
Expand Down
3 changes: 3 additions & 0 deletions runtime/python/treelite_runtime/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
def _load_runtime_lib():
"""Load Treelite runtime"""
lib_path = find_lib_path()
if sys.version_info >= (3, 8) and sys.platform == 'win32':
# pylint: disable=no-member
os.add_dll_directory(os.path.join(os.path.normpath(sys.prefix), 'Library', 'bin'))
lib = ctypes.cdll.LoadLibrary(lib_path[0])
lib.TreeliteGetLastError.restype = ctypes.c_char_p
lib.callback = _log_callback
Expand Down
2 changes: 2 additions & 0 deletions tests/python/test_lightgbm_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def test_sparse_categorical_model(tmpdir, quantize, toolchain):
pytest.xfail(reason='Clang cannot handle long if conditional')
if os_platform() == 'windows':
pytest.xfail(reason='MSVC cannot handle long if conditional')
if os_platform() == 'osx':
pytest.xfail(reason='Apple Clang cannot handle long if conditional')
dataset = 'sparse_categorical'
libpath = os.path.join(tmpdir, dataset_db[dataset].libname + _libext())
model = treelite.Model.load(dataset_db[dataset].model, model_format=dataset_db[dataset].format)
Expand Down
7 changes: 5 additions & 2 deletions tests/python/test_model_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
'dataset', ['mushroom', 'dermatology', 'letor', 'toy_categorical', 'sparse_categorical'])
def test_model_query(tmpdir, dataset):
"""Test all query functions for every example model"""
if dataset == 'sparse_categorical' and os_platform() == 'windows':
pytest.xfail('MSVC cannot handle long if conditional')
if dataset == 'sparse_categorical':
if os_platform() == 'windows':
pytest.xfail('MSVC cannot handle long if conditional')
elif os_platform() == 'osx':
pytest.xfail('Apple Clang cannot handle long if conditional')
if dataset == 'letor' and os_platform() == 'windows':
pytest.xfail('export_lib() is too slow for letor on MSVC')

Expand Down
5 changes: 1 addition & 4 deletions tests/travis/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ then
python -m pip install xgboost
python -m pip install lightgbm codecov
./build/treelite_cpp_test
export GCC_PATH=gcc-7
PYTHONPATH=./python:./runtime/python python -m pytest --cov=treelite --cov=treelite_runtime -v --fulltrace tests/python
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info '*dmlccore*' --output-file coverage.info
Expand All @@ -43,7 +42,7 @@ then
rm -rf build/
mkdir build
cd build
cmake .. -DUSE_OPENMP=ON -GNinja
cmake .. -DUSE_OPENMP=ON -DBUILD_STATIC_LIBS=ON -GNinja
ninja install

# Try compiling a sample application
Expand Down Expand Up @@ -92,7 +91,6 @@ then
conda install -c conda-forge numpy scipy pandas pytest scikit-learn coverage
python -m pip install xgboost
python -m pip install lightgbm
export GCC_PATH=gcc-7
python -m pytest -v --fulltrace tests/python

# Deploy binary wheel to S3
Expand Down Expand Up @@ -124,7 +122,6 @@ if [ ${TASK} == "python_sdist_test" ]; then
conda install -c conda-forge numpy scipy pandas pytest scikit-learn coverage
python -m pip install xgboost
python -m pip install lightgbm
export GCC_PATH=gcc-7
python -m pytest -v --fulltrace tests/python

# Deploy source wheel to S3
Expand Down