Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Boytsov authored and Leonid Boytsov committed Jul 6, 2018
2 parents 314f48e + 5cc7bea commit 67202cd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 33 deletions.
46 changes: 30 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ matrix:
- os: linux
env: PYTHON=3
- os: osx
env: PYTHON=3.6
env: PYTHON=3
osx_image: xcode9.3
python: 3.7.0
- os: osx
env: PYTHON=2
osx_image: xcode9.3
python: 2.7.14
allow_failures:
- os: osx

Expand All @@ -29,17 +35,27 @@ addons:

before_install:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi
if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "${PYTHON:0:1}" = "3" ]; then
brew update
brew upgrade python
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -;
rvm get stable
else
PIP=pip
PY=python
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
export CXX=g++-4.8 CC=gcc-4.8;
pip install --user --upgrade pip virtualenv
virtualenv -p python$PYTHON venv
source venv/bin/activate
fi
fi
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update
brew install gcc
PIP=pip2
PY=python2
if [ "${PYTHON:0:1}" = "3" ]; then
brew upgrade python
brew install python3
PIP=pip3
PY=python3
fi
fi
install:
- |
Expand All @@ -49,22 +65,20 @@ install:
cmake similarity_search
fi
make -j 4
travis_wait travis_retry pip install -r python_bindings/requirements.txt scipy six flake8
travis_retry cd python_bindings && python setup.py build install && cd ..
travis_wait travis_retry $PIP install -r python_bindings/requirements.txt scipy six flake8
travis_retry cd python_bindings && $PY setup.py build install && cd ..
script:
- $PY --version
- cd python_bindings && $PY setup.py test && flake8 && cd ..
- |
set -e
if [ "$TRAVIS_OS_NAME" = "linux" -o "$TRAVIS_OS_NAME" = "osx" ] ; then
if [ "$TRAVIS_OS_NAME" = "linux" ] ; then
cd similarity_search;
./release/bunit
./release/test_integr integr.log
cd ..
fi
cd python_bindings
python setup.py test
flake8
cd ..
cache:
- apt
Expand Down
43 changes: 26 additions & 17 deletions python_bindings/nmslib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,32 @@ class PythonLogger
int line,
const char * function,
const std::string & message) {
AcquireGIL l;
switch(severity) {
case LIB_DEBUG:
inner.attr("debug")(message);
break;
case LIB_INFO:
inner.attr("info")(message);
break;
case LIB_WARNING:
inner.attr("warning")(message);
break;
case LIB_ERROR:
inner.attr("error")(message);
break;
case LIB_FATAL:
inner.attr("critical")(message);
break;
// In cases when the interpreter was shutting down, attempting to log in python
// could throw an exception (https://github.com/nmslib/nmslib/issues/327).
// Logging shouldn't cause exceptions, so catch it and dump to stderr instead.
try {
AcquireGIL l;
switch(severity) {
case LIB_DEBUG:
inner.attr("debug")(message);
break;
case LIB_INFO:
inner.attr("info")(message);
break;
case LIB_WARNING:
inner.attr("warning")(message);
break;
case LIB_ERROR:
inner.attr("error")(message);
break;
case LIB_FATAL:
inner.attr("critical")(message);
break;
}
} catch (const std::exception & e) {
std::cerr << "Failed to log '" << message << "'. Exception:" << e.what() << std::endl;
} catch (...) {
std::cerr << "Failed to log '" << message << "'" << std::endl;
}
}
};
Expand Down
6 changes: 6 additions & 0 deletions python_bindings/tests/bindings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,11 @@ def testSparse(self):
self.assertEqual(index[3], [(3, 1.0)])


class GlobalTestCase(unittest.TestCase):
def testGlobal(self):
# this is a one line reproduction of https://github.com/nmslib/nmslib/issues/327
GlobalTestCase.index = nmslib.init()


if __name__ == "__main__":
unittest.main()

0 comments on commit 67202cd

Please sign in to comment.