Databricks Feature Store Client

0.17.0 · active · verified Mon Apr 13

The `databricks-feature-store` library provides a Python client for interacting with the Databricks Feature Store. It enables data scientists and ML engineers to create, manage, and discover features for machine learning models within the Databricks platform. The current version is 0.17.0. Its release cadence is typically aligned with Databricks Runtime updates, although specific release notes for this client library are often integrated into Databricks documentation.

Warnings

Install

Imports

Quickstart

Initializes the Databricks Feature Store Client. This library is primarily intended for use within a Databricks Runtime environment. While the client can be initialized locally, most operations (like creating or reading feature tables) require an active Spark session and proper connectivity to a Databricks workspace. The `pyspark` dependency is crucial for operations involving Spark DataFrames. The example demonstrates basic client initialization and highlights environmental dependencies.

import os
# pyspark.sql is often needed for operations using Spark DataFrames
# from pyspark.sql import SparkSession
from databricks.feature_store import FeatureStoreClient

# NOTE: This client is designed to run primarily within a Databricks Runtime environment.
# Running it locally typically requires an active Spark session and potentially
# Databricks SDK configuration for authentication.

try:
    # Initialize the FeatureStoreClient.
    # In a Databricks notebook, this usually works without arguments.
    # For local testing, it may require a configured Databricks SDK client or environment variables.
    fs = FeatureStoreClient()
    print("FeatureStoreClient initialized successfully.")
    print("Full functionality (e.g., creating/reading feature tables) requires a Spark session and Databricks connectivity.")

    # Example of a minimal operation (will likely fail if not in Databricks Runtime/Spark env)
    # if os.environ.get("DATABRICKS_RUNTIME_VERSION"):
    #     # This block would execute if running within Databricks
    #     print("Running within Databricks Runtime. Attempting to list feature tables...")
    #     # This requires a SparkSession, usually 'spark' is pre-initialized in DB Runtime
    #     # try:
    #     #     # To truly run this, you'd need 'spark' object which comes from pyspark
    #     #     # If running locally, you'd need to init SparkSession manually.
    #     #     # E.g., spark = SparkSession.builder.appName("local-fs").getOrCreate()
    #     #     # print(f"Number of feature tables: {len(fs.list_tables())}")
    #     # except Exception as e:
    #     #     print(f"Could not list tables: {e}")
    # else:
    #     print("Skipping full Feature Store operations: Not detected in Databricks Runtime.")

except Exception as e:
    print(f"Error initializing FeatureStoreClient: {e}")
    print("Please ensure you are in a Databricks Runtime or have a Spark session and Databricks SDK configured for full functionality.")

view raw JSON →