feature-function-serving-online-tables-dbsdk(Python)

Loading...

Feature Serving example notebook

Feature Serving lets you serve pre-materialized features and run on-demand computation for features.

This notebook illustrates how to:

  1. Create a FeatureSpec. A FeatureSpec defines a set of features (prematerialized and on-demand) that are served together.
  2. Create an Online Table from a Delta Table.
  3. Serve the features. To serve features, you create a Feature Serving endpoint with the FeatureSpec.

Requirements

This notebook requires Databricks Runtime for Machine Learning 14.2 or above.

Set up the Feature Table

To access the feature table from Feature Serving, you must create an Online Table from the feature table.

Feature table is used for offline training of models, and online table is used in online inference

Set up a Databricks Online Table

You can create an online table from the Catalog Explorer UI, Databricks SDK or Rest API. The steps to use Databricks python SDK are described below. For more details, see the Databricks documentation (AWS|Azure). For information about required permissions, see Permissions (AWS|Azure).

Create the function

The next cell defines a function that calculates the distance between the destination and the user's current location.

You can now view the FeatureSpec (travel_spec) and the distance function (distance) in Catalog Explorer. Click Catalog in the sidebar. In the Catalog Explorer, navigate to your schema in the main catalog. The FeatureSpec and the function appear under Functions.

Create a Feature Serving endpoint

You can now view the status of the Feature Serving Endpoint in the table on the Serving endpoints page. Click Serving in the sidebar to display the page.

Query

Clean up

When you are finished, delete the FeatureSpec, feature endpoint, and online table.

The online table can only be deleted from Catalog Explorer, as follows:

  1. In the left sidebar, click Catalog.
  2. Navigate to the online table.
  3. From the kebab menu, select Delete.

Run the following commands to delete the FeatureSpec and feature endpoint.