Skip to main content

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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

khiops_kni-11.0.1-py3-none-win_amd64.whl (1.9 MB view details)

Uploaded Python 3Windows x86-64

khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (8.6 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (8.3 MB view details)

Uploaded Python 3manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl (5.5 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl (6.1 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

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

Hashes for khiops_kni-11.0.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ae7562f187b405cd7fe09acf1b7dc81e1baadd411813a7c9215a87be8fbea179
MD5 62e41408b678f993b2a789b4a3ddc429
BLAKE2b-256 405c0ee1aed30a186ab1d1f93b35fc827b16a528b41550c8050728513c16283b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

File hashes

Hashes for khiops_kni-11.0.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c11db26ecf25ea67701b9389d33ad6e6019c3752d0c88da6ddf3cab89ce02912
MD5 eed4f64ba33c671d7e650ad634d7a72e
BLAKE2b-256 090d25fb18dd1477f1e4a99f884a4960e9943a138fee7c0b187236a0ced33432

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for khiops_kni-11.0.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 142d7b0bdf8d3ba5bb132addc7d395f46a3acbc5521f2909b5948fe62477ea9b
MD5 8fa814a129149a37aef0faa1706ee0b9
BLAKE2b-256 0e2ae6afd74bcdea8b9b72a2bdc4ecd743cb0a9b1e7eea78e24448fde4cff4be

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for khiops_kni-11.0.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aed6a87e220d3294123e702c8311c152571f75d0564453d5892ced915fe5d9d5
MD5 3bca5550efc8d3898b2aa1bf7fa7b205
BLAKE2b-256 8fc6f5b55d9dcda7c058597a2d9b21e3499092821e9e283205639d5c3c459200

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for khiops_kni-11.0.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c0b65c0001a8808640bedacd75e36cfddc98e0179d9823026378eaeea3d73d29
MD5 094a712d79b756c48255a1d5269e4260
BLAKE2b-256 84c0019d699c6fe7ae7bd09c3b7d9f940288026037805ec3995f034dd8d4d732

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page