Python SDK/Tool Development Guideline
Contents
Python SDK/Tool Development Guideline#
There are two modules in python/: Python SDK and an OpenMLDB diagnostic tool.
SDK Testing Methods#
Run the command make SQL_PYSDK_ENABLE=ON OPENMLDB_BUILD_TARGET=cp_python_sdk_so under the root directory and make sure the library in python/openmldb_sdk/openmldb/native/ was the latest native library.
Package installation test: Install the compiled
whl, then runpytest tests/. You can use the scriptsteps/test_python.shdirectly.Dynamic test: Make sure there isn’t OpenMLDB in
pipor the compiledwhl. Runpytest test/inpython/openmldb_sdk, thereby you can easily debug.
You can use the following commands for partial testing
cd python/openmldb_sdk
pytest tests/ -k '<keyword>'
pytest tests/xxx.py::<test_func>
pytest tests/xxx.py::<test_class>::<test_func>
See more about -k in keyword expressions.
Tool Testing#
Since the diagnosis tools need a password-free ssh, you need to register the local user’s ssh public key into the authorized_keys even in local testing (in which the local ssh is connected to local host).
For testing, please use:
cd python/openmldb_tool
pytest tests/
If the python log messages are required, please use:
pytest -o log_cli=true --log-cli-level=DEBUG tests/
Conda#
If you use conda, pytest may found the wrong python, then get errors like ModuleNotFoundError: No module named 'IPython'. Please use python -m pytest.