Skip to content

Commit

Permalink
[CI] Just use Apple Clang on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Jan 9, 2021
1 parent 0020e65 commit d431d2b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
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@10
- libomp
- wget
- lcov
Expand Down
4 changes: 3 additions & 1 deletion tests/python/test_lightgbm_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from treelite.contrib import _libext
from treelite.util import has_sklearn
from .metadata import dataset_db, _qualify_path
from .util import os_compatible_toolchains, os_platform, check_predictor
from .util import os_compatible_toolchains, os_platform, check_predictor, is_apple_clang

try:
import lightgbm
Expand Down 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' and is_apple_clang(toolchain):
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
11 changes: 7 additions & 4 deletions tests/python/test_model_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import treelite_runtime
from treelite.contrib import _libext
from .metadata import dataset_db
from .util import os_platform, os_compatible_toolchains
from .util import os_platform, os_compatible_toolchains, is_apple_clang

ModelFact = collections.namedtuple(
'ModelFact',
Expand All @@ -28,8 +28,12 @@
'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')
toolchain = os_compatible_toolchains()[0]
if dataset == 'sparse_categorical':
if os_platform() == 'windows':
pytest.xfail('MSVC cannot handle long if conditional')
elif os_platform() == 'osx' and is_apple_clang(toolchain):
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 All @@ -39,7 +43,6 @@ def test_model_query(tmpdir, dataset):
assert model.num_class == _model_facts[dataset].num_class
assert model.num_tree == _model_facts[dataset].num_tree

toolchain = os_compatible_toolchains()[0]
model.export_lib(toolchain=toolchain, libpath=libpath,
params={'quantize': 1, 'parallel_comp': model.num_tree}, verbose=True)
predictor = treelite_runtime.Predictor(libpath=libpath, verbose=True)
Expand Down
11 changes: 11 additions & 0 deletions tests/python/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
"""Utility functions for tests"""
import os
import subprocess
import re
from sys import platform as _platform
from contextlib import contextmanager

Expand Down Expand Up @@ -42,6 +44,15 @@ def os_platform():
return 'unix'


def is_apple_clang(toolchain):
try:
proc = subprocess.run([toolchain, '--version'], check=True, capture_output=True)
stdout = proc.stdout.decode('utf-8')
return re.search(r'Apple Clang', stdout, re.IGNORECASE):
except:
return False


def libname(fmt):
"""Format name for a shared library, using appropriate file extension"""
return fmt.format(_libext())
Expand Down
3 changes: 0 additions & 3 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-10
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 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-10
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-10
python -m pytest -v --fulltrace tests/python

# Deploy source wheel to S3
Expand Down

0 comments on commit d431d2b

Please sign in to comment.