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

Compare Python objects instead of proto objects #2227

Merged

Conversation

felixwang9817
Copy link
Collaborator

Signed-off-by: Felix Wang wangfelix98@gmail.com

What this PR does / why we need it: This PR switches Registry.diff_between and other helper methods to compare registry objects as Python objects instead of proto objects.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2022

Codecov Report

Merging #2227 (4da806e) into master (62fae05) will increase coverage by 0.28%.
The diff coverage is 90.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2227      +/-   ##
==========================================
+ Coverage   84.92%   85.21%   +0.28%     
==========================================
  Files         105      106       +1     
  Lines        8498     8568      +70     
==========================================
+ Hits         7217     7301      +84     
+ Misses       1281     1267      -14     
Flag Coverage Δ
integrationtests 72.61% <52.29%> (-0.78%) ⬇️
unittests 60.25% <89.08%> (+0.53%) ⬆️

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

Impacted Files Coverage Δ
sdk/python/feast/repo_operations.py 52.21% <40.00%> (+3.82%) ⬆️
sdk/python/feast/feature_service.py 82.35% <85.71%> (-0.99%) ⬇️
sdk/python/feast/diff/FcoDiff.py 98.91% <98.03%> (+9.82%) ⬆️
sdk/python/feast/feature_store.py 89.42% <100.00%> (-0.42%) ⬇️
sdk/python/feast/registry.py 83.50% <100.00%> (-0.11%) ⬇️
sdk/python/feast/repo_contents.py 100.00% <100.00%> (ø)
...ts/integration/feature_repos/repo_configuration.py 94.28% <100.00%> (+0.05%) ⬆️
sdk/python/tests/unit/diff/test_fco_diff.py 100.00% <100.00%> (ø)

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 62fae05...4da806e. Read the comment docs.

),
feature_services=set(self.list_feature_services(project=project)),
)

# TODO(achals): This method needs to be filled out and used in the feast plan/apply methods.
@staticmethod
def diff_between(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method seems to logically belong as a method within RegistryDiff or something. You no longer are passing in registry protos at least

Copy link
Collaborator

Choose a reason for hiding this comment

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

my comment still loosely applies. We'll want to eventually do inferencing here as well to resolve the RepoContents to their exact registry form (e.g. including schema, inferred features in a FV, and feature projections in a feature service). A "diff" method to me seems to suggest a much simpler implementation than that.

Would also see this as belong in the same file as where we do inferencing, which I think technically is in feature_store.py. That file is getting a bit large too though. We probably could use some sort of RepoContents -> Registry converter that does this inference logic for feast plan and feast apply

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup this is fair - I moved this method to FcoDiff.py

sdk/python/feast/registry.py Outdated Show resolved Hide resolved
sdk/python/feast/registry.py Outdated Show resolved Hide resolved
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
sdk/python/feast/feature_store.py Outdated Show resolved Hide resolved
current_registry: RegistryProto, new_registry: RegistryProto
) -> RegistryDiff:
diff = RegistryDiff()
def extract_objects_for_keep_delete_update_add(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems oddly placed here now. (also type annotations please)

I think the only place you call this is in repo_operations and don't see any reason why other classes would ever call this, so maybe throw this there instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note that this is also called in diff_between, but still a fair point - it doesn't quite belong with the Registry, so I moved it to FcoDiff.py

),
feature_services=set(self.list_feature_services(project=project)),
)

# TODO(achals): This method needs to be filled out and used in the feast plan/apply methods.
@staticmethod
def diff_between(
Copy link
Collaborator

Choose a reason for hiding this comment

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

my comment still loosely applies. We'll want to eventually do inferencing here as well to resolve the RepoContents to their exact registry form (e.g. including schema, inferred features in a FV, and feature projections in a feature service). A "diff" method to me seems to suggest a much simpler implementation than that.

Would also see this as belong in the same file as where we do inferencing, which I think technically is in feature_store.py. That file is getting a bit large too though. We probably could use some sort of RepoContents -> Registry converter that does this inference logic for feast plan and feast apply

@@ -65,6 +66,16 @@
"": "LocalRegistryStore",
}

REGISTRY_OBJECT_TYPE_TO_STR = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason why we can't use the original type name and need to remove the underscores?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we want to convert plural -> single, so removing underscores doesn't quite do it

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see.. this is because we use them directly in feast plan output to the console.

Mind making a comment explaining why this mapping exists? Also, it may make more sense to store this map closer to where it's used (i.e. near some feast plan file or in what today is repo_operations)

)

objs_to_keep[object_type] = to_keep
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of having these mapped by object type? Seems like the caller of this immediately flattens it back into one big list. That also seems to introduce this need to look at REGISTRY_OBJECT_TYPES

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we map these by object type because diff_between uses extract_objects_for_keep_delete_update_add, and diff_between needs to know the keep/delete/update/add split by object type in order to compare objects of the same type

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
@felixwang9817 felixwang9817 force-pushed the feast_plan_compare_python_objects branch from d2e700d to ab2c9cb Compare January 24, 2022 18:40
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Signed-off-by: Felix Wang <wangfelix98@gmail.com>
@felixwang9817
Copy link
Collaborator Author

/retest

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
sdk/python/feast/diff/FcoDiff.py Outdated Show resolved Hide resolved
sdk/python/feast/diff/FcoDiff.py Outdated Show resolved Hide resolved
@@ -65,6 +66,16 @@
"": "LocalRegistryStore",
}

REGISTRY_OBJECT_TYPE_TO_STR = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see.. this is because we use them directly in feast plan output to the console.

Mind making a comment explaining why this mapping exists? Also, it may make more sense to store this map closer to where it's used (i.e. near some feast plan file or in what today is repo_operations)

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
Copy link
Collaborator

@adchia adchia left a comment

Choose a reason for hiding this comment

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

/lgtm

sdk/python/feast/diff/FcoDiff.py Show resolved Hide resolved
sdk/python/feast/diff/FcoDiff.py Show resolved Hide resolved
sdk/python/feast/diff/FcoDiff.py Show resolved Hide resolved
@feast-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adchia, felixwang9817

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:
  • OWNERS [adchia,felixwang9817]

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 3dcec6d into feast-dev:master Jan 25, 2022
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.

5 participants