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

Add Python bindings #105

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
94d231d
Install pybind
ll-nick Oct 8, 2024
4b83fa7
Add basic pybind structure and bind dummy behavior
ll-nick Oct 8, 2024
2408f98
Bind abstract behavior, DummyBehavior and add python unit test equiva…
ll-nick Oct 10, 2024
947ada2
Bind YAML printing via std::string
ll-nick Oct 10, 2024
84a4bc9
Re-implement DummyBehavior in python and run equivalent unit test
ll-nick Oct 10, 2024
99fe5a3
Fix linter warnings, tidy up
ll-nick Oct 10, 2024
60b8f73
Create a testing submodule
ll-nick Oct 10, 2024
ea87760
Bind the placebo verifier
ll-nick Oct 10, 2024
4630942
Bind the abstract Arbitrator
ll-nick Oct 10, 2024
8a6748d
Bind the priority arbitrator
ll-nick Oct 10, 2024
099b02a
Fix unit test for priority arbitrator with different subcommand
ll-nick Oct 11, 2024
4bae4de
Bind the cost arbitrator incl. cost estimator
ll-nick Oct 11, 2024
6bced45
Fix unit test for cost arbitrator with different sub command
ll-nick Oct 11, 2024
e3f7d68
Add a python implemented cost estimator and unit test
ll-nick Oct 11, 2024
8020cdb
Build bindings only if test are enabled, copy test to build directory
ll-nick Oct 11, 2024
fbd62a5
Add centralized binding function and reorder files
ll-nick Oct 11, 2024
969517d
Tidy up python print tests
ll-nick Oct 14, 2024
38413ac
Add python equivalent of nested_arbitrators.cpp test case
ll-nick Oct 14, 2024
04e3a77
Remove to_stream bindings
ll-nick Oct 14, 2024
269d1a5
Tidy up for consistency
ll-nick Oct 14, 2024
70b03c6
Make the py test ouput a little prettier
ll-nick Oct 14, 2024
9ef9976
Bind exceptions
ll-nick Oct 14, 2024
7886578
Bind conjunctive coordinator
ll-nick Oct 14, 2024
fc31afa
Add test for conjunctive coordinator with different sub command
ll-nick Oct 14, 2024
33e54aa
Move DummyVerifier definition into dummy_types.hpp
ll-nick Oct 14, 2024
d112187
Merge command differs from sub command tests into one file
ll-nick Oct 14, 2024
2f96827
Bind DummyVerifier
ll-nick Oct 14, 2024
557daf9
Add python equivalent of verification.cpp test case
ll-nick Oct 15, 2024
f26d902
Restructure bindings for expected print outputs
ll-nick Oct 16, 2024
2c6e54c
Add verified conjunctive coordinator test case to verification.cpp
ll-nick Oct 16, 2024
062be19
Add bindings and unit test for JointCoordinator
ll-nick Oct 16, 2024
f60f261
Adjust DummyVerifier to allow rejecting everything
ll-nick Oct 17, 2024
faa1a30
Add missing verification tests of JointCoordinator to verifier.py
ll-nick Oct 17, 2024
1cfb3c4
Add missing joint coordinator test for different subcommand
ll-nick Oct 17, 2024
b32781e
Bind random arbitrator and add corresponding py unit test
ll-nick Oct 17, 2024
6307606
Add missing random arbitrator test for different sub command
ll-nick Oct 17, 2024
ae2b21b
Remove some unnecessary trampoline classes
ll-nick Oct 17, 2024
ecd18e9
Fix test file path since tests now have their own CMakeLists.txt
ll-nick Dec 18, 2024
9396e69
Add python tests as ctests
ll-nick Dec 18, 2024
1d6e654
PlaceboResult.isOk is no longer static
ll-nick Dec 18, 2024
b14ed2d
Remove duplicated import
ll-nick Dec 18, 2024
c2a20c1
Rename python files containing tests to _test.py to easily distinguis…
ll-nick Dec 18, 2024
3ef743b
Fit pybind documentation into updated Readme structure
ll-nick Dec 18, 2024
41caffd
Bind util_caching types
ll-nick Dec 18, 2024
39a60cc
Remove toYaml bindings
ll-nick Dec 18, 2024
e28824f
Pass unittest flag to python executable to make sure error code is se…
ll-nick Dec 19, 2024
ee43976
Fix wrong boolean in python test
ll-nick Dec 19, 2024
bf8e41e
Add python bindings in contribution section
ll-nick Dec 19, 2024
584563d
Final cleanup before merging
ll-nick Dec 19, 2024
66bd8a1
Pass the entire binding name instead of just a suffix for the Behavio…
ll-nick Jan 7, 2025
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
Prev Previous commit
Next Next commit
Rename python files containing tests to _test.py to easily distinguis…
…h them in cmake.

This also tidies up the CMakeLists a little bit for the python tests.
  • Loading branch information
ll-nick committed Dec 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c2a20c17faa5d0e3852115bfec4ea44e114721af
18 changes: 12 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -97,10 +97,9 @@ endif()
#######################

if(pybind11_FOUND)
# Find Python3 to run tests via ctest
find_package(Python3 REQUIRED)

# Python bindings modules
# Build the individual pybind modules
pybind11_add_module(arbitration_graphs_py
python_bindings.cpp
)
@@ -120,13 +119,20 @@ if(pybind11_FOUND)
arbitration_graphs
)

file(GLOB_RECURSE _py_tests CONFIGURE_DEPENDS "*.py")
# Copy required modules to the build directory
# These do not contain tests but are roughly equivalent to the C++ test-specific header files.
configure_file(cost_estimator.py cost_estimator.py COPYONLY)
configure_file(dummy_types.py dummy_types.py COPYONLY)

# Copy Python test files to build directory
# Copy Python test files to the build directory and add them as tests.
# Of course, python tests do not need to be compiled.
# However, we can easily import the compiled pybind11 module if they are in the same directory.
# We also want to be able run the using ctest to keep things consistent with the C++ tests.
file(GLOB_RECURSE _py_tests CONFIGURE_DEPENDS "*_test.py")
foreach(_py_test ${_py_tests})
get_filename_component(_py_test_name ${_py_test} NAME)
string(REGEX REPLACE "-test" "" PY_TEST_NAME ${_py_test_name})
set(PY_TEST_NAME ${PROJECT_NAME}-pytest-${PY_TEST_NAME})
string(REGEX REPLACE "_test" "" PY_TEST_NAME ${_py_test_name})
set(PY_TEST_NAME arbitration_graphs-pytest-${PY_TEST_NAME})

message(STATUS
"Adding python unittest \"${PY_TEST_NAME}\" with working dir ${PROJECT_SOURCE_DIR}/${TEST_FOLDER} \n _test: ${_py_test}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.