Skip to main content

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 integer
  • get_full_version() - Get full version string
  • set_log_file_name(log_file_name) - Set error log file
  • open_stream(dictionary_file_name, dictionary_name, header_line, field_separator) - Open a stream
  • close_stream(stream_handle) - Close a stream
  • recode_stream_record(stream_handle, input_record) - Recode a record
  • set_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 stream
  • set_secondary_input_record(stream_handle, data_path, input_record) - Set secondary record (multi-table)
  • get_stream_max_memory() - Get max memory for stream
  • set_stream_max_memory(max_mb) - Set max memory for stream
  • get_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.

Metadata

Release files for khiops-kni 11.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for khiops-kni 11.0.1
File
khiops_kni-11.0.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 Details
khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 30.4 MB

Release files / khiops_kni-11.0.1-py3-none-win_amd64.whl

Download URL khiops_kni-11.0.1-py3-none-win_amd64.whl
Size 1.9 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ae7562f187b405cd7fe09acf1b7dc81e1baadd411813a7c9215a87be8fbea179
BLAKE2b-256 checksum
How to use checksums
405c0ee1aed30a186ab1d1f93b35fc827b16a528b41550c8050728513c16283b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 8.6 MB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c11db26ecf25ea67701b9389d33ad6e6019c3752d0c88da6ddf3cab89ce02912
BLAKE2b-256 checksum
How to use checksums
090d25fb18dd1477f1e4a99f884a4960e9943a138fee7c0b187236a0ced33432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 8.3 MB
Tags Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
142d7b0bdf8d3ba5bb132addc7d395f46a3acbc5521f2909b5948fe62477ea9b
BLAKE2b-256 checksum
How to use checksums
0e2ae6afd74bcdea8b9b72a2bdc4ecd743cb0a9b1e7eea78e24448fde4cff4be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl

Download URL khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl
Size 5.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aed6a87e220d3294123e702c8311c152571f75d0564453d5892ced915fe5d9d5
BLAKE2b-256 checksum
How to use checksums
8fc6f5b55d9dcda7c058597a2d9b21e3499092821e9e283205639d5c3c459200
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl

Download URL khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl
Size 6.1 MB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c0b65c0001a8808640bedacd75e36cfddc98e0179d9823026378eaeea3d73d29
BLAKE2b-256 checksum
How to use checksums
84c0019d699c6fe7ae7bd09c3b7d9f940288026037805ec3995f034dd8d4d732
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

11.0.1 This release

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page