openfheorg / openfhe-python

Official Python wrapper for OpenFHE. Current release is v0.8.10 (released on October 28, 2024).
https://openfheorg.github.io/openfhe-python/html/index.html
BSD 2-Clause "Simplified" License
83 stars 21 forks source link

pytest issues with get_native_int #177

Open anithag opened 1 month ago

anithag commented 1 month ago

After installing openfhe-python, I am trying to run pytest in the project root directory. I get the following errors. It must be something simple. Can you help fix? I am using Mac OSX Sonoma (Apple M2).

============================================================= ERRORS =============================================================
_______________________________________________ ERROR collecting tests/test_bgv.py _______________________________________________
tests/test_bgv.py:7: in <module>
    pytestmark = pytest.mark.skipif(fhe.get_native_int() == 32, reason="Doesn't work for NATIVE_INT=32")
E   AttributeError: module 'openfhe' has no attribute 'get_native_int'
______________________________________________ ERROR collecting tests/test_ckks.py _______________________________________________
tests/test_ckks.py:6: in <module>
    pytestmark = pytest.mark.skipif(fhe.get_native_int() == 32, reason="Doesn't work for NATIVE_INT=32")
E   AttributeError: module 'openfhe' has no attribute 'get_native_int'
__________________________________________ ERROR collecting tests/test_cryptocontext.py __________________________________________
tests/test_cryptocontext.py:4: in <module>
    pytestmark = pytest.mark.skipif(fhe.get_native_int() != 128, reason="Only for NATIVE_INT=128")
E   AttributeError: module 'openfhe' has no attribute 'get_native_int'
____________________________________________ ERROR collecting tests/test_examples.py _____________________________________________
tests/test_examples.py:10: in <module>
    pytestmark = pytest.mark.skipif(fhe.get_native_int() == 32, reason="Doesn't work for NATIVE_INT=32")
E   AttributeError: module 'openfhe' has no attribute 'get_native_int'
____________________________________________ ERROR collecting tests/test_serial_cc.py ____________________________________________
tests/test_serial_cc.py:6: in <module>
    pytestmark = pytest.mark.skipif(fhe.get_native_int() == 32, reason="Doesn't work for NATIVE_INT=32")
E   AttributeError: module 'openfhe' has no attribute 'get_native_int'
==================================================== short test summary info =====================================================
ERROR tests/test_bgv.py - AttributeError: module 'openfhe' has no attribute 'get_native_int'
ERROR tests/test_ckks.py - AttributeError: module 'openfhe' has no attribute 'get_native_int'
ERROR tests/test_cryptocontext.py - AttributeError: module 'openfhe' has no attribute 'get_native_int'
ERROR tests/test_examples.py - AttributeError: module 'openfhe' has no attribute 'get_native_int'
ERROR tests/test_serial_cc.py - AttributeError: module 'openfhe' has no attribute 'get_native_int'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
anithag commented 1 month ago

I want to provide a bit more info to see if this is an installation issue. openfhe is installed in my home directory. After build and install of openfhe-python, I have set PYTHONPATH and LD_LIBRARY_PATH to include openfhe dynamically shared libraries. So far it seemed reasonable without any issues.

Later, when I run pytest, I got the error:

Traceback:
/opt/homebrew/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_serial_cc.py:4: in <module>
    import openfhe as fhe
openfhe/__init__.py:1: in <module>
    from openfhe.openfhe import *
E   ModuleNotFoundError: No module named 'openfhe.openfhe'

What should my PYTHONPATH include at this point? Note that if it includes only $HOME//Users/anitha_gollamudi/openfhe-development/install/lib I get No module named openfhe.openfhe error.

anithag commented 1 month ago

setting export PYTHONPATH=openfhe-python/build:$PYTHONPATH solved the issue. This is not mentioned in the documentation; only OpenFHE libraries were mentioned, and I assumed that they referred to libraries from openfhe-development.