From ba29aaccec1d26abe1c23f9e8334da8897b2de74 Mon Sep 17 00:00:00 2001 From: Matt Green Date: Wed, 13 Nov 2024 12:42:34 -0800 Subject: [PATCH] docs: update Streaming feature computation with Denormalized Signed-off-by: Matt Green --- docs/reference/denormalized.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/reference/denormalized.md b/docs/reference/denormalized.md index 281e97de55..9ac39947f0 100644 --- a/docs/reference/denormalized.md +++ b/docs/reference/denormalized.md @@ -6,8 +6,8 @@ Denormalized makes it easy to compute real-time features and write them directly ## Prerequisites -- Python 3.8+ -- Kafka cluster (local or remote) +- Python 3.12+ +- Kafka cluster (local or remote) OR docker installed For a full working demo, check out the [feast-example](https://github.com/probably-nothing-labs/feast-example) repo. @@ -39,6 +39,13 @@ my-feature-project/ └── main.py # Pipeline runner ``` +3. Run a test Kafka instance in docker + +`docker run --rm -p 9092:9092 emgeee/kafka_emit_measurements:latest` + +This will spin up a docker container that runs a kafka instance and run a simple script to emit fake data to two topics. + + ## Define Your Features In `feature_repo/sensor_data.py`, define your feature view and entity: @@ -85,7 +92,7 @@ sample_event = { } # Create a stream from your Kafka topic -ds = FeastDataStream(Context().from_topic("temperature", json.dumps(sample_event), "localhost:9092")) +ds = FeastDataStream(Context().from_topic("temperature", json.dumps(sample_event), "localhost:9092", "occurred_at_ms")) # Define your feature computations ds = ds.window( @@ -106,7 +113,9 @@ feature_store = FeatureStore(repo_path="feature_repo/") ds.write_feast_feature(feature_store, "push_sensor_statistics") ``` + + ## Need Help? - Email us at hello@denormalized.io -- Check out more examples on our [GitHub](https://github.com/probably-nothing-labs/denormalized) +- Check out more examples on our [GitHub](https://github.com/probably-nothing-labs/denormalized/tree/main/py-denormalized/python/examples)