Creating or connecting to a feature storeΒΆ
Note
The Snowflake Feature Store API is available in the Snowpark ML Python package (snowflake-ml-python
) v1.5.0 and later.
Create a feature store or connect to an existing feature store by using the FeatureStore
constructor, providing a
Snowpark session, database name, feature store name, and default warehouse name. The mode
parameter determines
whether the feature store is created if it does not already exist.
Mode |
Description |
---|---|
|
Throws an exception if the specified feature store does not exist. Default. |
|
Creates the feature store if it does not exist. |
To create a feature store, use the CreationMode.CREATE_IF_NOT_EXIST
mode when instantiating FeatureStore
.
Creating a feature store creates a schema in the specified database with the specified feature store name. Generally,
an administrator role will create the feature store schema and corresponding roles.
You can subsequently connect to the existing feature store by using the default mode, CreationMode.FAIL_IF_NOT_EXIST
.
The following Python code creates a feature store:
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,
)
Tip
Storing your feature stores in a dedicated database will make it simpler to replicate them.
After you have created a feature store, use code like the following to access it:
from snowflake.ml.feature_store import FeatureStore, CreationMode
fs = FeatureStore(
session=session,
database="MY_DB",
name="MY_FEATURE_STORE",
default_warehouse="MY_WH",
)