Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 5 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ jobs:
working-directory: ${{ runner.temp }}/build/tests
run: ctest -C ${{ matrix.build_type }}

- name: Run Cpp Examples
env:
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{ runner.temp }}/build/examples/cpp
run: ctest -C RelWithDebugInfo
84 changes: 84 additions & 0 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Python Test
run-name: ${{ github.event.inputs.run_name || github.event.pull_request.title }}

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
python-build:
name: ${{ matrix.cxx }}
runs-on: self-hosted
strategy:
matrix:
cxx:
- g++-11
- clang++-13
include:
- cxx: g++-11
cc: gcc-11
- cxx: clang++-13
cc: clang-13

steps:
- uses: actions/checkout@v4

- name: Install MKL
timeout-minutes: 5
run: |
.github/scripts/setup_apt_repo_linux.sh
sudo apt install intel-oneapi-mkl intel-oneapi-mkl-devel
# Setup environment variables for building against MKL.
# Persist the environment variables for use across multiple subsequent actions.
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV

# Install inside the temporary working directory.
- name: Build Wheel
env:
CXX: ${{ matrix.cxx }}
CC: ${{ matrix.cc }}
TEMP_WORKSPACE: ${{ runner.temp }}/usr
run: |
cd ${GITHUB_WORKSPACE}/bindings/python
python setup.py bdist_wheel --cmake-executable="cmake" --build-type=RelWithDebugInfo -- -- -j$(nproc)
pip install ./dist/scalable_vs*.whl --target=${TEMP_WORKSPACE}

# Make sure to add the location of the generated wheel to the python path.
- name: Run tests
env:
PYTHONPATH: ${{ runner.temp }}/usr
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{ runner.temp }}
run: python -m unittest discover -s ${GITHUB_WORKSPACE}/bindings/python

- name: Run examples
env:
PYTHONPATH: ${{ runner.temp }}/usr
CTEST_OUTPUT_ON_FAILURE: 1
working-directory: ${{ runner.temp }}
run: python -m unittest discover -p "example*.py" -s ${GITHUB_WORKSPACE}/examples/python
10 changes: 6 additions & 4 deletions examples/python/example_vamana.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
# [imports]

DEBUG_MODE = False
def assert_equal(lhs, rhs, message: str = ""):
def assert_equal(lhs, rhs, message: str = "", epsilon = 0.05):
if DEBUG_MODE:
print(f"{message}: {lhs} == {rhs}")
else:
assert lhs == rhs, message
assert lhs < rhs + epsilon, message
assert lhs > rhs - epsilon, message

def run_test_float(index, queries, groundtruth):
expected = {
Expand Down Expand Up @@ -79,6 +80,7 @@ def run_test_build_two_level4_8(index, queries, groundtruth):
test_data_dir = None

def run():
epsilon = 0.05

# ###
# Generating test data
Expand Down Expand Up @@ -159,7 +161,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8288)
assert_equal(recall, 0.8288)
# [perform-queries]

# [search-window-size]
Expand Down Expand Up @@ -213,7 +215,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8288)
assert_equal(recall, 0.8288)
# [loading]

##### Begin Test
Expand Down
12 changes: 7 additions & 5 deletions examples/python/example_vamana_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
# [imports]

DEBUG_MODE = False
def assert_equal(lhs, rhs, message: str = ""):
def assert_equal(lhs, rhs, message: str = "", epsilon = 0.05):
if DEBUG_MODE:
print(f"{message}: {lhs} == {rhs}")
else:
assert lhs == rhs, message
assert lhs < rhs + epsilon, message
assert lhs > rhs - epsilon, message

def run_test_float(index, queries, groundtruth):
expected = {
Expand All @@ -48,6 +49,8 @@ def run_test_float(index, queries, groundtruth):
test_data_dir = None

def run():
epsilon = 0.05

# [generate-dataset]
# Create a test dataset.
# This will create a directory "example_data_vamana" and populate it with three
Expand Down Expand Up @@ -118,7 +121,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8202)
assert_equal(recall, 0.8202)
# [perform-queries]

##### Begin Test
Expand Down Expand Up @@ -158,8 +161,7 @@ def run():
# Compare with the groundtruth.
recall = svs.k_recall_at(groundtruth, I, 10, 10)
print(f"Recall = {recall}")
assert(recall == 0.8202)

assert_equal(recall, 0.8202)

##### Begin Test
run_test_float(index, queries, groundtruth)
Expand Down
Loading