Skip to content

Added .with_name method in FeatureView/OnDemandFeatureView classes for name aliasing. FeatureViewProjection will hold this information - #1872

Merged
feast-ci-bot merged 14 commits into
feast-dev:masterfrom
mavysavydav:1867
Oct 7, 2021

Conversation

@mavysavydav

Copy link
Copy Markdown
Collaborator

Signed-off-by: David Y Liu davidyliuliu@gmail.com

What this PR does / why we need it:
#1867

Which issue(s) this PR fixes:

Fixes #1867

Does this PR introduce a user-facing change?:

Added ".with_name" public method to FeatureView class as part of the shadow entities mapping implementation which will enable users to join a FeatureView to entity data more than once and therefore there may be feature name conflicts. For more context, see the shadow entities mapping RFC here - https://docs.google.com/document/d/1TsCwKf3nVXTAfL0f8i26jnCgHA3bRd4dKQ8QdM87vIA/edit#. 

@feast-ci-bot

Copy link
Copy Markdown
Collaborator

Hi @mavysavydav. Thanks for your PR.

I'm waiting for a feast-dev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov-commenter

codecov-commenter commented Sep 16, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1872 (91595cf) into master (b1ccf8d) will decrease coverage by 0.12%.
The diff coverage is 65.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1872      +/-   ##
==========================================
- Coverage   82.34%   82.22%   -0.13%     
==========================================
  Files          96       96              
  Lines        7490     7512      +22     
==========================================
+ Hits         6168     6177       +9     
- Misses       1322     1335      +13     
Flag Coverage Δ
integrationtests 73.84% <58.62%> (-0.08%) ⬇️
unittests 60.06% <44.82%> (-0.07%) ⬇️

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

Impacted Files Coverage Δ
sdk/python/feast/errors.py 70.07% <ø> (ø)
...python/feast/infra/offline_stores/offline_utils.py 90.10% <ø> (ø)
sdk/python/feast/feature_view.py 84.33% <33.33%> (-1.92%) ⬇️
sdk/python/feast/on_demand_feature_view.py 86.15% <33.33%> (-2.56%) ⬇️
sdk/python/tests/unit/test_feature_validation.py 83.33% <50.00%> (-16.67%) ⬇️
sdk/python/feast/feature_store.py 94.36% <100.00%> (+0.02%) ⬆️
sdk/python/feast/feature_view_projection.py 100.00% <100.00%> (ø)
sdk/python/feast/infra/provider.py 90.67% <100.00%> (ø)
sdk/python/feast/cli.py 38.79% <0.00%> (-0.49%) ⬇️
... and 4 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 b1ccf8d...91595cf. Read the comment docs.

@mavysavydav mavysavydav added the kind/feature New feature or request label Sep 16, 2021
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Comment thread sdk/python/feast/feature_view.py Outdated
@woop

woop commented Sep 16, 2021

Copy link
Copy Markdown
Member

Btw @mavysavydav your thoughts on #1868 (comment) would be appreciated since it may slightly change this PR.

@codyjlin

Copy link
Copy Markdown
Contributor

We may want to add another case to the FeatureNameCollisionError error message to reflect that they might also need to use .with_name if they're trying to use join on multiple featureviews with the same name (i.e. in the shadow entities case) since full_feature_names=True won't be enough.

class FeatureNameCollisionError(Exception):
def __init__(self, feature_refs_collisions: List[str], full_feature_names: bool):
if full_feature_names:
collisions = [ref.replace(":", "__") for ref in feature_refs_collisions]
error_message = (
"To resolve this collision, please ensure that the features in question "
"have different names."
)
else:
collisions = [ref.split(":")[1] for ref in feature_refs_collisions]
error_message = (
"To resolve this collision, either use the full feature name by setting "
"'full_feature_names=True', or ensure that the features in question have different names."
)

@mavysavydav

mavysavydav commented Sep 24, 2021

Copy link
Copy Markdown
Collaborator Author

Cool, added the FeatureNameCollisionError msg modification

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
@feast-ci-bot feast-ci-bot added size/L and removed size/M labels Oct 6, 2021
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
@mavysavydav

Copy link
Copy Markdown
Collaborator Author

/retest

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

@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, mavysavydav

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

@mavysavydav mavysavydav changed the title Added .with_name method in FeatureView class Added .with_name method in FeatureView/OnDemandFeatureView classes for name aliasing. FeatureViewProjection will hold this information Oct 7, 2021
@feast-ci-bot
feast-ci-bot merged commit cc95c75 into feast-dev:master Oct 7, 2021
string feature_view_name = 1;

// Alias for feature view name
string feature_view_name_to_use = 3;

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.

I dont think this is an appropriate name. "Name to use" is confusing if you dont understand the context. What if it's unset, would we use a blank string?

What about feature_view_name_alias?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

name_alias seemed like an obvious choice, but it didn't seem to fit for the following reason. My thinking was that name_to_use defaults to the name and it always has a value. Either the alias or the original name. So when projection.name_to_use is used, the name that will be used is returned, whereas with projection.name_alias, one might think -- does it have an alias set? If not, should I do a check? To me, name_to_use is less conventional than a term like an alias, but it seems clear in meaning "the name that will be used". I can see how ppl may find it unfamiliar though and maybe hesitate to assume that it means exactly as it's worded especially if they don't know the use case. Happy to change it.

@woop woop Oct 7, 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.

So when projection.name_to_use is used, the name that will be used is returned, whereas with projection.name_alias, one might think -- does it have an alias set? If not, should I do a check?

I think this is where I see it differently. The caller shouldn't have to check which one is set. They should just ask for name. We should be able to place the conditional logic within a Python property, right?

Of course, we do need a different name in that case though. We can't just have name refer to both the original and the name that has been aliased.

So perhaps

field: name
field: name_alias

method: get_name()
or
method: name_to_use()

In the latter case I am slightly more comfortable with name_to_use since at a storage level we are still keeping the fields separate and clear. My beef with name_to_use is really that it's not a descriptive name. It doesnt convey its meaning. Shouldnt all the code we write be usable? Ideally we'd have something more specific imho, but I dont have any good ideas except above.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok works for me. I'll make the change

@dataclass
class FeatureViewProjection:
name: str
name_to_use: str

@woop woop Oct 7, 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.

What about just alias or name_alias?


def with_name(self, name: str):
"""
Produces a copy of this OnDemandFeatureView with the passed name.

@woop woop Oct 7, 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.

What isn't clear is why?
What about
Renames this feature view by setting an alias for the feature view name. This rename operation is only used as part of query operations and will not modify the underlying feature view.?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good

Comment thread sdk/python/feast/on_demand_feature_view.py
felixwang9817 pushed a commit to felixwang9817/feast that referenced this pull request Oct 7, 2021
…r name aliasing. FeatureViewProjection will hold this information (feast-dev#1872)

* Added .with_name method in FV with test case

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Correctly sort imports

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* correct lint errors

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Modified FeatureNameCollisionError msg

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* fixed error msg test

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* updated code to preserve original FV name in base_name field

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Updated proto conversion methods and fixed failures

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* fixed proto numberings

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* wip

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Cleaned code up

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* added copy method in FVProjections

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* use python's copy lib rather than creating new copy method.

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
felixwang9817 pushed a commit to felixwang9817/feast that referenced this pull request Oct 7, 2021
…r name aliasing. FeatureViewProjection will hold this information (feast-dev#1872)

* Added .with_name method in FV with test case

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Correctly sort imports

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* correct lint errors

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Modified FeatureNameCollisionError msg

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* fixed error msg test

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* updated code to preserve original FV name in base_name field

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Updated proto conversion methods and fixed failures

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* fixed proto numberings

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* wip

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* Cleaned code up

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* added copy method in FVProjections

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>

* use python's copy lib rather than creating new copy method.

Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
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.

Add ".with_name" method to FeatureView (Part of shadow entities mapping changes)

6 participants