Skip to content

Commit

Permalink
Add tests for python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
BUYT-1 committed Aug 9, 2023
1 parent b89cf53 commit 70682e1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
workflow_dispatch:
jobs:
test-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download libraries
uses: ./.github/composite-actions/download-libraries
with:
download-pybind: true
- name: Configure CMake
run: >
cmake -B ${{github.workspace}}/build
-DCMAKE_C_COMPILER=gcc-10
-DCMAKE_CXX_COMPILER=g++-10
-DBOOST_ROOT=${{github.workspace}}/lib/boost
-DCMAKE_BUILD_TYPE=Release
-Dgtest_disable_pthreads=OFF
-DASAN=OFF
-DCOMPILE_PYBIND=ON
-DCOMPILE_TESTS=OFF
- name: Build
run: cmake --build ${{github.workspace}}/build --config Release
- name: Test
working-directory: ${{github.workspace}}/build/python_bindings
shell: bash
run: python testing_script.py
6 changes: 6 additions & 0 deletions python_bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ file(GLOB_RECURSE sources "*.h*" "*.cpp*")
pybind11_add_module(${BINDINGS_NAME} ${sources})

target_link_libraries(${BINDINGS_NAME} PRIVATE ${CMAKE_PROJECT_NAME}_lib)

add_custom_command(TARGET ${BINDINGS_NAME}
COMMAND ${CMAKE_COMMAND} -E
copy ${CMAKE_SOURCE_DIR}/python_bindings/testing_script.py
${CMAKE_BINARY_DIR}/python_bindings/
)
13 changes: 13 additions & 0 deletions python_bindings/testing_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from inspect import getmembers, isclass

import desbordante as desb

for name, type_ in getmembers(desb, isclass):
# Assumes no classes inherit from algorithms.
if not (type_.__module__ == 'desbordante' and issubclass(type_, desb.FdAlgorithm)
and not type_.__subclasses__()):
continue
algorithm = type_()
algorithm.load_data('../target/input_data/iris.csv', ',', False)
algorithm.execute()
print(name, algorithm.get_fds())

0 comments on commit 70682e1

Please sign in to comment.