Skip to content

Implement entity aliasing for feature retrieval - #1868

Merged
feast-ci-bot merged 23 commits into
feast-dev:masterfrom
codyjlin:shadow-entities
Oct 11, 2021
Merged

Implement entity aliasing for feature retrieval#1868
feast-ci-bot merged 23 commits into
feast-dev:masterfrom
codyjlin:shadow-entities

Conversation

@codyjlin

Copy link
Copy Markdown
Contributor

Signed-off-by: Cody Lin codyl@twitter.com

What this PR does / why we need it:

This PR implements the Shadow Entities Mapping RFC - currently assuming we go with Option 8b (and the implementation idea at the bottom of the RFC). It will allow a user to override a FeatureView's join_key (like "user_id") to be able to join with an entity_df source that might have other column names that are spelled differently or might be "subclasses" of the entity (like "spammer_id" and "reporter_id"). This functionality is to be made available on the offline side via get_historical_features and the online side via get_online_features.

TODO:

  • testing to come
  • will add changes to redshift.py once changes to bigquery.py are reasonable/approved, and/or testing is ready

Which issue(s) this PR fixes:

Part of #1762
(Might want to add documentation after change is landed)

Does this PR introduce a user-facing change?:

User can now override the join keys of a FeatureView if the entity column name(s) are misspelled or
don't match the entity column name of the entity_df.
This can be done:
- by setting the FeatureView.join_key_map attribute
- at use-time FV in the FeatureService.features attribute via FeatureView.with_join_key_map(join_key_map)

@codyjlin codyjlin added the kind/feature New feature or request label Sep 15, 2021
@codyjlin
codyjlin requested review from a team, achals, tsotnet and woop as code owners September 15, 2021 21:18
Comment thread sdk/python/feast/feature_store.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is use_time a term people use? It wasn't immediately clear to me what this meant. I was also imagining that the logic for manipulating the feature view would be on the feature view itself, not a separate method.

Finally, you should add type annotations please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Definitely open to alternatives of use_time - I agree that it's not clear, but I'm not sure how else to describe it or what to rename it to. Basically instead of grabbing all of the registered FeatureViews, we need to grab any changes that the user wants to specify at the time of using the FeatureView (like the join_key_map or a new name).

  2. By "the logic for manipulating the feature view would be on the feature view itself", do you mean .override_join_keys or .with_join_key_map should manipulate the original object? I feel like we wouldn't want that behavior with this design given one might use it multiple times in different contexts.

  3. Will do in next commit 👌

@woop woop Sep 16, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely open to alternatives of use_time - I agree that it's not clear, but I'm not sure how else to describe it or what to rename it to. Basically instead of grabbing all of the registered FeatureViews, we need to grab any changes that the user wants to specify at the time of using the FeatureView (like the join_key_map or a new name).

I'd first want to see if we can avoid naming it at all. My instinct would have been to use a class like FeatureViewProjection which already supports filtering columns, and adding more options like renaming the feature view or overriding the join key. We may change it over time to be FeatureViewQuery or something. That would also prevent somebody from doing fv.with_name("blah") and then accidentally registering that FV, since we only anticipate the use of renaming to be for queries.

By "the logic for manipulating the feature view would be on the feature view itself", do you mean .override_join_keys or .with_join_key_map should manipulate the original object? I feel like we wouldn't want that behavior with this design given one might use it multiple times in different contexts.

Not override the original object, but instead produce a new object. It's just that the logic itself seems like it is better to have on the feature view class itself, basically what @mavysavydav did with with_name(). Although in his case he is returning a FV, but I think we may want to return another object that is specifically used for queries.

@woop

woop commented Sep 16, 2021

Copy link
Copy Markdown
Member

Please remember to add documentation to this PR as well.

Comment thread sdk/python/feast/feature_store.py Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoot, just realized these are all FeatureViewProjection objects cause it converts the features after initializing a FeatureService...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dependent on a PR by @mavysavydav to have FeatureService.features allow FeatureView as one of the types.

Comment thread sdk/python/tests/integration/offline_store/test_universal_historical_retrieval.py Outdated
@codecov-commenter

codecov-commenter commented Sep 22, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1868 (44b4e49) into master (314447f) will increase coverage by 0.24%.
The diff coverage is 99.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1868      +/-   ##
==========================================
+ Coverage   82.02%   82.26%   +0.24%     
==========================================
  Files          96       96              
  Lines        7576     7669      +93     
==========================================
+ Hits         6214     6309      +95     
+ Misses       1362     1360       -2     
Flag Coverage Δ
integrationtests 74.15% <99.19%> (+0.43%) ⬆️
unittests 59.39% <25.80%> (-0.48%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
sdk/python/feast/infra/offline_stores/redshift.py 85.00% <ø> (ø)
...marks/test_benchmark_universal_online_retrieval.py 32.00% <50.00%> (ø)
sdk/python/feast/driver_test_data.py 100.00% <100.00%> (ø)
sdk/python/feast/feature_store.py 94.54% <100.00%> (+0.08%) ⬆️
sdk/python/feast/feature_view.py 87.50% <100.00%> (+2.03%) ⬆️
sdk/python/feast/feature_view_projection.py 100.00% <100.00%> (ø)
sdk/python/feast/infra/offline_stores/file.py 97.50% <100.00%> (+0.06%) ⬆️
...python/feast/infra/offline_stores/offline_utils.py 90.21% <100.00%> (+0.10%) ⬆️
...ts/integration/feature_repos/repo_configuration.py 100.00% <100.00%> (ø)
...ts/integration/feature_repos/universal/entities.py 100.00% <100.00%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 314447f...44b4e49. Read the comment docs.

Cody Lin added 6 commits October 7, 2021 10:36
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
@codyjlin
codyjlin force-pushed the shadow-entities branch 3 times, most recently from 2272583 to 78ac430 Compare October 7, 2021 23:34
@achals

achals commented Oct 7, 2021

Copy link
Copy Markdown
Member

/ok-to-test

Signed-off-by: Cody Lin <codyl@twitter.com>
@codyjlin

codyjlin commented Oct 8, 2021

Copy link
Copy Markdown
Contributor Author

/retest

Cody Lin and others added 5 commits October 7, 2021 20:43
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Comment thread sdk/python/tests/integration/offline_store/test_universal_historical_retrieval.py Outdated
Comment thread sdk/python/feast/feature_store.py
Comment thread sdk/python/tests/integration/online_store/test_universal_online.py Outdated
Signed-off-by: Cody Lin <codyl@twitter.com>
Comment thread sdk/python/feast/feature_view.py Outdated
Comment thread sdk/python/feast/feature_view.py Outdated
Comment thread sdk/python/feast/feature_view.py Outdated
Cody Lin added 2 commits October 8, 2021 15:12
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Comment thread protos/feast/core/FeatureViewProjection.proto Outdated
Comment thread sdk/python/feast/feature_store.py Outdated
Comment thread sdk/python/feast/feature_store.py Outdated
@achals

achals commented Oct 11, 2021

Copy link
Copy Markdown
Member

looks mostly good, looking at the integ test code which was a bit more involved

Cody Lin added 3 commits October 11, 2021 11:55
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
Signed-off-by: Cody Lin <codyl@twitter.com>
@achals achals changed the title Implement shadow entities mapping functionality Implement entity aliasing for feature retrival Oct 11, 2021

@achals achals left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@feast-ci-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: achals, codyjlin

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@feast-ci-bot
feast-ci-bot merged commit f1df40a into feast-dev:master Oct 11, 2021
@codyjlin
codyjlin deleted the shadow-entities branch October 11, 2021 22:51
@mavysavydav mavysavydav changed the title Implement entity aliasing for feature retrival Implement entity aliasing for feature retrieval Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants