Skip to main content
Version: 0.4

Reading Online Features for Inference using the Python SDK (for Testing)

danger

Using the Python SDK to read online features is not recommended in production. It's much slower and is not designed for production workloads.

Authenticating with an API key​

If you're using an EMR or Databricks notebook that has been configured to work with Tecton, you can skip this section as the API key is already configured.

Creating an API key​

An HTTP API request is authenticated using an API key, which a Service Account contains.

Create an API key with the CLI by running the following command. This command also creates a Service Account containing the API key. The Service Account is created on the Tecton instance that you are logged into.

tecton api-key create --description "A sample key for the documentation"

Go to the Permissions screen for your workspace and add your new Service Account to the workspace. Then grant the Consumer, Editor, or Owner role to the Service Account.

Configuring your notebook to use an API key​

import tecton

tecton.conf.set("TECTON_API_KEY", "my-key-code")

Using the FeatureService.get_online_features() method (for testing)​

To fetch online features from a Feature Service containing both OnDemand Feature Views and materialized Feature Views, provide both join_keys and request_data as inputs. If your Feature Service only includes materialized Feature Views then you can omit the request_data input, and vice-versa.

import tecton

my_fs = tecton.get_feature_service("fraud_detection_feature_service")

keys = {"user_id": "C1000262126"}

request_data = {"amount": 100}

response = my_fs.get_online_features(join_keys=keys, request_data=request_data)
response.to_dict()

See the API reference for details.

Was this page helpful?

Happy React is loading...