-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix issue with feature views being detected as duplicated when imported #1905
Fix issue with feature views being detected as duplicated when imported #1905
Conversation
Signed-off-by: Achal Shah <achals@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1905 +/- ##
===========================================
+ Coverage 62.30% 82.99% +20.69%
===========================================
Files 96 96
Lines 7353 7357 +4
===========================================
+ Hits 4581 6106 +1525
+ Misses 2772 1251 -1521
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice !
I tried couple of the inspect functions like getsourcefile()
in the other PR but could not make it work.
It makes sense to track where the objects are created 👍
sdk/python/feast/repo_operations.py
Outdated
@@ -107,15 +107,20 @@ def parse_repo(repo_root: Path) -> ParsedRepo: | |||
for attr_name in dir(module): | |||
obj = getattr(module, attr_name) | |||
if isinstance(obj, FeatureTable): | |||
res.feature_tables.append(obj) | |||
if obj.defined_in is not None and obj.defined_in == module.__file__: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can module.file be None ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should maybe also raise exceptions in case defined_in is None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. And no, module.file cannot be None
sdk/python/feast/entity.py
Outdated
stack = inspect.stack() | ||
# Get two levels up from current, to ignore usage.py | ||
previous_stack_frame = stack[2] | ||
self.defined_in = previous_stack_frame.filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we abstract that in an helper function and also test it in a test file ?
Don't think we need to test each class but at least the helper function
What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A helper class probably makes sense since there's some state tracking being done. wdyt @achals ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A helper class
yeah even better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Just to play devil's advocate here. Tracking the file names does add complexity to our objects. Is there any reason we cant import all the objects and use built in functionality |
IMO updating |
Signed-off-by: Achal Shah <achals@gmail.com>
sdk/python/feast/feature_table.py
Outdated
stack = inspect.stack() | ||
# Get two levels up from current, to ignore usage.py | ||
previous_stack_frame = stack[2] | ||
self.defined_in = previous_stack_frame.filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like missing one get_calling_file_name()
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah missed this
@@ -188,6 +188,7 @@ def online_read( | |||
|
|||
for entity_key in entity_keys: | |||
redis_key_bin = _redis_key(project, entity_key) | |||
print(redis_key_bin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be removed ?
Signed-off-by: Achal Shah <achals@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: achals, adchia 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 |
Signed-off-by: Achal Shah <achals@gmail.com>
New changes are detected. LGTM label has been removed. |
Whether or not there is a bug here, I am not 100% convinced by the approach taken here. There are many reasons to support object equality, deduplication just being one of them. Reaching into the filesystem seems like it will be a lot more prone to errors since its OS/env dependent. |
I'm coming around to this view point after this bug as well. It's pretty easy to get wrong. I'm going to undo this change and use equality based deduping. |
Signed-off-by: Achal Shah <achals@gmail.com>
* Use set when parsing repos to prevent duplicates Signed-off-by: Achal Shah <achals@gmail.com> * Undo #1905 changes Signed-off-by: Achal Shah <achals@gmail.com> * use id() in addition to name to differentiate different objects with the same name Signed-off-by: Achal Shah <achals@gmail.com> * add a test Signed-off-by: Achal Shah <achals@gmail.com> * add one more test Signed-off-by: Achal Shah <achals@gmail.com> * remove debugging Signed-off-by: Achal Shah <achals@gmail.com>
Signed-off-by: Achal Shah achals@gmail.com
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #1895
Does this PR introduce a user-facing change?: