Khiops Native Interface (KNI) - Python bindings and C library for model deployment and scoring.
Project description
Khiops Native Interface (KNI) - Python Package
Python bindings for the Khiops Native Interface (KNI), enabling direct deployment of Khiops models from Python without temporary files.
Installation
pip install khiops-kni
Quick Start
from kni import KNI
# Initialize KNI wrapper
kni = KNI()
# Open a stream for recoding
stream_handle = kni.open_stream(
dictionary_file_name="model.kdic",
dictionary_name="MyDictionary",
header_line="feature1\tfeature2\tfeature3",
field_separator="\t"
)
# Recode records
input_record = "value1\tvalue2\tvalue3"
ret_code, output_record = kni.recode_stream_record(stream_handle, input_record)
if ret_code == KNI.KNI_OK:
print(f"Output: {output_record}")
else:
print(f"Error: {kni.get_error_message(ret_code)}")
# Close the stream
kni.close_stream(stream_handle)
Features
- Cross-platform: Works on Windows, Linux, and macOS
- Easy to use: Pythonic API wrapping the C library
- High performance: Direct C library calls via ctypes
- Multi-table support: Handle complex multi-table schemas
- Comprehensive error handling: Clear error messages for debugging
API Overview
KNI Class
Main class for interacting with the Khiops Native Interface.
Methods
get_version()- Get KNI version as integerget_full_version()- Get full version stringset_log_file_name(log_file_name)- Set error log fileopen_stream(dictionary_file_name, dictionary_name, header_line, field_separator)- Open a streamclose_stream(stream_handle)- Close a streamrecode_stream_record(stream_handle, input_record)- Recode a recordset_secondary_header_line(stream_handle, data_path, header_line)- Set secondary table header (multi-table)set_external_table(stream_handle, data_root, data_path, data_table_file_name)- Set external table (multi-table)finish_opening_stream(stream_handle)- Finish opening multi-table streamset_secondary_input_record(stream_handle, data_path, input_record)- Set secondary record (multi-table)get_stream_max_memory()- Get max memory for streamset_stream_max_memory(max_mb)- Set max memory for streamget_error_message(error_code)- Get human-readable error message
Multi-Table Example
from kni import KNI
kni = KNI()
# Open stream with main table header
stream_handle = kni.open_stream(
"model.kdic", "MainDict", "id\tname\tvalue", "\t"
)
# Set secondary table header
kni.set_secondary_header_line(
stream_handle, "Details", "detail_id\tmain_id\tinfo"
)
# Set external table
kni.set_external_table(
stream_handle, "RefData", "", "reference.txt"
)
# Finish opening for multi-table
kni.finish_opening_stream(stream_handle)
# Set secondary records before recoding main record
kni.set_secondary_input_record(stream_handle, "Details", "1\t100\tinfo1")
kni.set_secondary_input_record(stream_handle, "Details", "2\t100\tinfo2")
# Recode main record
ret_code, output = kni.recode_stream_record(stream_handle, "100\tJohn\t42")
kni.close_stream(stream_handle)
Requirements
- Python 3.10 or later
- The KhiopsNativeInterface C library is bundled with this package
License
BSD-3-Clause-Clear
Links
Support
For questions or issues, please visit the issue tracker or contact khiops.team@orange.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file khiops_kni-11.0.1-py3-none-win_amd64.whl.
File metadata
- Download URL: khiops_kni-11.0.1-py3-none-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae7562f187b405cd7fe09acf1b7dc81e1baadd411813a7c9215a87be8fbea179
|
|
| MD5 |
62e41408b678f993b2a789b4a3ddc429
|
|
| BLAKE2b-256 |
405c0ee1aed30a186ab1d1f93b35fc827b16a528b41550c8050728513c16283b
|
Provenance
The following attestation bundles were made for khiops_kni-11.0.1-py3-none-win_amd64.whl:
Publisher:
pack-pip.yml on KhiopsML/khiops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khiops_kni-11.0.1-py3-none-win_amd64.whl -
Subject digest:
ae7562f187b405cd7fe09acf1b7dc81e1baadd411813a7c9215a87be8fbea179 - Sigstore transparency entry: 2036763130
- Sigstore integration time:
-
Permalink:
KhiopsML/khiops@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Branch / Tag:
refs/tags/11.0.1 - Owner: https://github.com/KhiopsML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pack-pip.yml@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 8.6 MB
- Tags: Python 3, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c11db26ecf25ea67701b9389d33ad6e6019c3752d0c88da6ddf3cab89ce02912
|
|
| MD5 |
eed4f64ba33c671d7e650ad634d7a72e
|
|
| BLAKE2b-256 |
090d25fb18dd1477f1e4a99f884a4960e9943a138fee7c0b187236a0ced33432
|
Provenance
The following attestation bundles were made for khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pack-pip.yml on KhiopsML/khiops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
c11db26ecf25ea67701b9389d33ad6e6019c3752d0c88da6ddf3cab89ce02912 - Sigstore transparency entry: 2036762534
- Sigstore integration time:
-
Permalink:
KhiopsML/khiops@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Branch / Tag:
refs/tags/11.0.1 - Owner: https://github.com/KhiopsML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pack-pip.yml@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 8.3 MB
- Tags: Python 3, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
142d7b0bdf8d3ba5bb132addc7d395f46a3acbc5521f2909b5948fe62477ea9b
|
|
| MD5 |
8fa814a129149a37aef0faa1706ee0b9
|
|
| BLAKE2b-256 |
0e2ae6afd74bcdea8b9b72a2bdc4ecd743cb0a9b1e7eea78e24448fde4cff4be
|
Provenance
The following attestation bundles were made for khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
pack-pip.yml on KhiopsML/khiops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
142d7b0bdf8d3ba5bb132addc7d395f46a3acbc5521f2909b5948fe62477ea9b - Sigstore transparency entry: 2036766050
- Sigstore integration time:
-
Permalink:
KhiopsML/khiops@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Branch / Tag:
refs/tags/11.0.1 - Owner: https://github.com/KhiopsML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pack-pip.yml@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aed6a87e220d3294123e702c8311c152571f75d0564453d5892ced915fe5d9d5
|
|
| MD5 |
3bca5550efc8d3898b2aa1bf7fa7b205
|
|
| BLAKE2b-256 |
8fc6f5b55d9dcda7c058597a2d9b21e3499092821e9e283205639d5c3c459200
|
Provenance
The following attestation bundles were made for khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl:
Publisher:
pack-pip.yml on KhiopsML/khiops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
aed6a87e220d3294123e702c8311c152571f75d0564453d5892ced915fe5d9d5 - Sigstore transparency entry: 2036765293
- Sigstore integration time:
-
Permalink:
KhiopsML/khiops@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Branch / Tag:
refs/tags/11.0.1 - Owner: https://github.com/KhiopsML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pack-pip.yml@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0b65c0001a8808640bedacd75e36cfddc98e0179d9823026378eaeea3d73d29
|
|
| MD5 |
094a712d79b756c48255a1d5269e4260
|
|
| BLAKE2b-256 |
84c0019d699c6fe7ae7bd09c3b7d9f940288026037805ec3995f034dd8d4d732
|
Provenance
The following attestation bundles were made for khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl:
Publisher:
pack-pip.yml on KhiopsML/khiops
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl -
Subject digest:
c0b65c0001a8808640bedacd75e36cfddc98e0179d9823026378eaeea3d73d29 - Sigstore transparency entry: 2036764135
- Sigstore integration time:
-
Permalink:
KhiopsML/khiops@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Branch / Tag:
refs/tags/11.0.1 - Owner: https://github.com/KhiopsML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pack-pip.yml@8ae32728a470bc3bb69663ebe1da3cb48b16fb1f -
Trigger Event:
workflow_dispatch
-
Statement type: