snowflakedb / snowflake-ml-python

Apache License 2.0
37 stars 7 forks source link

Unable to register feature store in demo notebook #71

Closed brazils closed 3 months ago

brazils commented 7 months ago

I am trying to step through the demo notebook in ml/feature_store/notebooks/customer_demo/Basic_Feature_Demo.ipynb

I run this block in the notebook

fv = FeatureView(
    name="WINE_FEATURES", 
    entities=[entity], 
    feature_df=feature_df, 
    desc="wine features"
)
fs.register_feature_view(
    feature_view=fv, 
    version="V1", 
    refresh_freq="1 minute", 
    block=True
)

This is the output:

/Users/<redacted>/projects/snowflake-ml-python/snowflake/ml/feature_store/feature_store.py:1062: UserWarning: Dynamic table: `FEATURE_STORE_BASIC_FEATURE_NOTEBOOK_DEMO.AWESOME_FS_BASIC_FEATURES.WINE_FEATURES$V1` will not refresh in INCREMENTAL mode. It will likely incurr bigger computation cost. The reason is: Query contains the function 'SEQ8', but change tracking is not supported on queries with non-deterministic functions.
  warnings.warn(
FeatureView(_name=WINE_FEATURES, _entities=[Entity(name=WINE, join_keys=['WINE_ID'], desc=)], _feature_df=<snowflake.snowpark.dataframe.DataFrame object at 0x7fefcad74e80>, _timestamp_col=None, _desc=wine features, _query=SELECT seq8(0) AS "WINE_ID", "FIXED_ACIDITY", "VOLATILE_ACIDITY", "CITRIC_ACID", "RESIDUAL_SUGAR", "CHLORIDES", "FREE_SULFUR_DIOXIDE", "TOTAL_SULFUR_DIOXIDE", "DENSITY", "PH", ("FIXED_ACIDITY" * "CITRIC_ACID") AS "MY_NEW_FEATURE" FROM FEATURE_STORE_BASIC_FEATURE_NOTEBOOK_DEMO.TEST_DATASET.WINE_DATA, _version=V1, _status=FeatureViewStatus.RUNNING, _feature_desc=OrderedDict([('FIXED_ACIDITY', None), ('VOLATILE_ACIDITY', None), ('CITRIC_ACID', None), ('RESIDUAL_SUGAR', None), ('CHLORIDES', None), ('FREE_SULFUR_DIOXIDE', None), ('TOTAL_SULFUR_DIOXIDE', None), ('DENSITY', None), ('PH', None), ('MY_NEW_FEATURE', None)]), _refresh_freq=1 minute' initialize = 'ON_CREATE, _database=FEATURE_STORE_BASIC_FEATURE_NOTEBOOK_DEMO, _schema=AWESOME_FS_BASIC_FEATURES, _warehouse=FEATURE_STORE_BASIC_FEATURE_NOTEBOOK_DEMO, _refresh_mode=FULL, _refresh_mode_reason=Query contains the function 'SEQ8', but change tracking is not supported on queries with non-deterministic functions.)

Then running the next block

# Examine the FeatureView content
fs.read_feature_view(fv).show()

I get this error:


SnowflakeMLException                      Traceback (most recent call last)
File ~/opt/anaconda3/envs/snowml/lib/python3.8/site-packages/snowflake/ml/_internal/telemetry.py:310, in send_api_usage_telemetry.<locals>.decorator.<locals>.wrap(*args, **kwargs)
    309 try:
--> 310     res = func(*args, **kwargs)
    311 except Exception as e:

File ~/opt/anaconda3/envs/snowml/lib/python3.8/site-packages/snowflake/snowpark/_internal/utils.py:620, in func_decorator.<locals>.wrapper.<locals>.func_call_wrapper(*args, **kwargs)
    619 warning(func.__qualname__, warning_text)
--> 620 return func(*args, **kwargs)

File ~/projects/snowflake-ml-python/snowflake/ml/feature_store/feature_store.py:371, in FeatureStore.read_feature_view(self, feature_view)
    370 if feature_view.status == FeatureViewStatus.DRAFT or feature_view.version is None:
--> 371     raise snowml_exceptions.SnowflakeMLException(
    372         error_code=error_codes.NOT_FOUND,
    373         original_exception=ValueError(f"FeatureView {feature_view.name} has not been registered."),
    374     )
    376 return self._session.sql(f"SELECT * FROM {feature_view.fully_qualified_name()}")

SnowflakeMLException: ValueError('(2101) FeatureView WINE_FEATURES has not been registered.')

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
Cell In[104], line 2
      1 # Examine the FeatureView content
----> 2 fs.read_feature_view(fv).show()

File ~/opt/anaconda3/envs/snowml/lib/python3.8/site-packages/snowflake/ml/_internal/telemetry.py:330, in send_api_usage_telemetry.<locals>.decorator.<locals>.wrap(*args, **kwargs)
    328         raise e.original_exception from None
    329     else:
--> 330         raise e.original_exception from e
    331 else:
    332     return res

ValueError: (2101) FeatureView WINE_FEATURES has not been registered.```
sfc-gh-wezhou commented 7 months ago

Hi @brazils , the reason you are getting this error is because fv is not registered. To make it work, simply:fv = fs.register_feature_view(...). BTW, I believe you're running out-of-date notebook against newer code. This notebook has been updated a while ago.

sfc-gh-shchen commented 6 months ago

Hi @brazils have you had the chance to try out the approach @sfc-gh-wezhou suggested above?

sfc-gh-wzhao commented 3 months ago

I am closing this stale issue. If you have any problem, please re-open it.