Last active
August 10, 2020 18:27
-
-
Save chinmaychandak/4d0692379bdf4856d86a30c0af075229 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
To stream from Kafka, please refer to the streamz API here: https://streamz.readthedocs.io/en/latest/api.html#sources | |
You can refer to https://kafka.apache.org/quickstart to start a local Kafka cluster. | |
Below is an example snippet to start a stream from Kafka. | |
''' | |
from custreamz import kafka | |
# Kafka topic to read streaming data from | |
topic = "word-count" | |
# Kafka brokers | |
bootstrap_servers = 'localhost:9092' | |
# Kafka consumer configuration | |
consumer_conf = {'bootstrap.servers': bootstrap_servers, | |
'group.id': 'custreamz', | |
'session.timeout.ms': 60000} | |
''' | |
If you changed Dask=True, please ensure you have a Dask cluster up and running. Refer to this for Dask API: https://docs.dask.org/en/latest/ | |
If the input data is high throughput, we recommend using Dask, and starting appropriate number of Dask workers. | |
In case of high-throughput processing jobs, please set appropriate number of Kafka topic partitions to ensure parallelism. | |
To leverage the custreamz' accelerated Kafka reader (note that data in Kafka must be JSON format), use engine="cudf". | |
''' | |
source = Stream.from_kafka_batched(topic, consumer_conf, npartitions=1, poll_interval='10s', | |
asynchronous=True, dask=False, engine="cudf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment