Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 14 commits into from
Oct 7, 2021

Conversation

mavysavydav
Copy link
Collaborator

Signed-off-by: David Y Liu [email protected]

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
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.

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
Copy link

codecov-commenter commented Sep 16, 2021

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
@woop
Copy link
Member

woop commented Sep 16, 2021

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

@codyjlin
Copy link
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
Copy link
Collaborator Author

mavysavydav commented Sep 24, 2021

Cool, added the FeatureNameCollisionError msg modification

Signed-off-by: David Y Liu <[email protected]>
Signed-off-by: David Y Liu <[email protected]>
Signed-off-by: David Y Liu <[email protected]>
@feast-ci-bot feast-ci-bot added size/L and removed size/M labels Oct 6, 2021
Signed-off-by: David Y Liu <[email protected]>
@mavysavydav
Copy link
Collaborator Author

/retest

Signed-off-by: David Y Liu <[email protected]>
Copy link
Member

@achals achals left a comment

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
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

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
@@ -14,6 +14,9 @@ message FeatureViewProjection {
// The feature view name
string feature_view_name = 1;

// Alias for feature view name
string feature_view_name_to_use = 3;
Copy link
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
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.

Copy link
Member

@woop woop Oct 7, 2021

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
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

@@ -11,11 +11,12 @@
@dataclass
class FeatureViewProjection:
name: str
name_to_use: str
Copy link
Member

@woop woop Oct 7, 2021

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?

@@ -68,6 +69,25 @@ def __init__(
def __hash__(self) -> int:
return hash((id(self), self.name))

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

@woop woop Oct 7, 2021

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
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good

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 <[email protected]>

* Correctly sort imports

Signed-off-by: David Y Liu <[email protected]>

* correct lint errors

Signed-off-by: David Y Liu <[email protected]>

* Modified FeatureNameCollisionError msg

Signed-off-by: David Y Liu <[email protected]>

* fixed error msg test

Signed-off-by: David Y Liu <[email protected]>

* updated code to preserve original FV name in base_name field

Signed-off-by: David Y Liu <[email protected]>

* Updated proto conversion methods and fixed failures

Signed-off-by: David Y Liu <[email protected]>

* fixed proto numberings

Signed-off-by: David Y Liu <[email protected]>

* wip

Signed-off-by: David Y Liu <[email protected]>

* Cleaned code up

Signed-off-by: David Y Liu <[email protected]>

* added copy method in FVProjections

Signed-off-by: David Y Liu <[email protected]>

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

Signed-off-by: David Y Liu <[email protected]>
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 <[email protected]>

* Correctly sort imports

Signed-off-by: David Y Liu <[email protected]>

* correct lint errors

Signed-off-by: David Y Liu <[email protected]>

* Modified FeatureNameCollisionError msg

Signed-off-by: David Y Liu <[email protected]>

* fixed error msg test

Signed-off-by: David Y Liu <[email protected]>

* updated code to preserve original FV name in base_name field

Signed-off-by: David Y Liu <[email protected]>

* Updated proto conversion methods and fixed failures

Signed-off-by: David Y Liu <[email protected]>

* fixed proto numberings

Signed-off-by: David Y Liu <[email protected]>

* wip

Signed-off-by: David Y Liu <[email protected]>

* Cleaned code up

Signed-off-by: David Y Liu <[email protected]>

* added copy method in FVProjections

Signed-off-by: David Y Liu <[email protected]>

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

Signed-off-by: David Y Liu <[email protected]>
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