Skip to main content

Add your description here

Project description

tkati-core

For now we assume that each node gets one input and produces one output in a form of kafka stream.

Settings

General form of settings is:

[input.topic]
# definition of input stream:
# - broker
# - topic name
# - message schema
# - message format = "json" / "arrow-batch"

[input.consumer]
# parameters local to this consumer
# - group_id
# - batch_size
# - batch_timeout_sec
# - auto_offset_reset

[output.topic]
# definition of output stream
# - broker
# - topic name
# - message schema
# - message format = "json" / "arrow-batch"
# - key_column (optional) = column to use as the Kafka message key

[...]
# settings specific to node function

Usage

Constructing a consumer from settings

Use KafkaArrowConsumer.from_input_settings to construct a consumer directly from KafkaInputSettings — no need to manually map fields to Confluent Kafka config keys.

from tkati_core.settings import TomlBaseSettings, KafkaInputSettings
from tkati_core.consumer import KafkaArrowConsumer

class AppSettings(TomlBaseSettings):
    input: KafkaInputSettings
    # ...

settings = AppSettings()
consumer = KafkaArrowConsumer.from_input_settings(settings.input)

# Read a batch
table = consumer.read_to_pyarrow(
    aggregation_interval_seconds=settings.input.consumer.batch_timeout_sec,
    max_events_to_aggregate=settings.input.consumer.batch_size,
)
consumer.commit()

The factory method sets enable.auto.commit=False — offsets must be committed explicitly via consumer.commit().

Constructing a producer from settings

Use KafkaArrowProducer.from_output_settings to construct a producer directly from KafkaOutputSettings. It accepts PyArrow tables or record batches and handles serialization according to the topic's format setting.

from tkati_core.settings import TomlBaseSettings, KafkaOutputSettings
from tkati_core.producer import KafkaArrowProducer

class AppSettings(TomlBaseSettings):
    output: KafkaOutputSettings
    # ...

settings = AppSettings()
producer = KafkaArrowProducer.from_output_settings(settings.output)

# Produce a PyArrow table (one message per row for "json" format)
producer.produce(table)
producer.flush()
producer.close()  # flushes and releases resources

Formats — controlled by output.topic.format in settings.toml:

  • "json" (default): each row becomes a separate Kafka message serialized with orjson.
  • "arrow-batch": the entire table is serialized as a single Arrow IPC stream message.

Message keys — controlled by output.topic.key_column in settings.toml:

[output.topic]
broker = "localhost:9092"
name = "my-output-topic"
key_column = "customer_id"   # column whose value becomes the Kafka message key

key_column is optional. When omitted (or None), messages are produced without a key. When set, the value of that column for each row is used as the Kafka message key (JSON format only — ignored for "arrow-batch"). This determines which Kafka partition each message is routed to.

Project details


Download files

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

Source Distribution

tkati_core-0.2.0.post1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

tkati_core-0.2.0.post1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file tkati_core-0.2.0.post1.tar.gz.

File metadata

  • Download URL: tkati_core-0.2.0.post1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tkati_core-0.2.0.post1.tar.gz
Algorithm Hash digest
SHA256 1e056850d88f3ab7d66abb29543f55ad007dc62b58dae8235bd08f270acf94d6
MD5 42e355ba29a0a9f69aaf1a3dac765576
BLAKE2b-256 3a425cdc7977df16c08a9e0fa19b4bb23357dbb5d93b4beb8242e39521e0095a

See more details on using hashes here.

File details

Details for the file tkati_core-0.2.0.post1-py3-none-any.whl.

File metadata

  • Download URL: tkati_core-0.2.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tkati_core-0.2.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d15dd434da86cb3b5f1222f36d9bc38c9da9f1f0692975ff9676312ffacd70
MD5 a02996b8f7a9d39deaa6c3a85ee2de98
BLAKE2b-256 88b4cb2157350420c0c13b9f01541ead3eb8db518763b9b1402a7243f272564d

See more details on using hashes here.

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