Creating or Connecting to a Feature Store¶
Create a feature store, or connect to an existing feature store instance, by providing a Snowpark session, database
name, feature store name and default warehouse name to the FeatureStore
constructor. The mode
parameter
determines whether the feature store is created if it does not already exist.
When a feature store is created, a schema in the specified database is created with the feature store name. Generally, an admin role will create the feature store schema and corresponding roles. After the back end exists, feature store clients (with consumer roles) can use FAIL_IF_NOT_EXIST mode, which is the default.
To create a feature store, use the CreationMode.CREATE_IF_NOT_EXIST
mode when instantiating FeatureStore
.
You can subsequently connect to the existing feature store using CreationMode.FAIL_IF_NOT_EXIST
mode.
CreationMode.FAIL_IF_NOT_EXIST
is the default mode.
Creating the feature store looks like this:
from snowflake.ml.feature_store import FeatureStore, CreationMode
fs = FeatureStore(
session=session,
database="MY_DB",
name="MY_FEATURE_STORE",
default_warehouse="MY_WH",
creation_mode=CreationMode.CREATE_IF_NOT_EXIST,
)
Subsequent use of the feature store looks like this:
fs = FeatureStore(
session=session,
database="MY_DB",
name="MY_FEATURE_STORE",
default_warehouse="MY_WH",
)