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

Allow apply to take a single Entity or FeatureView #1457

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def delete_feature_view(self, name: str):

return self._registry.delete_feature_view(name, self.project)

def apply(self, objects: List[Union[FeatureView, Entity]]):
def apply(
self, objects: Union[Entity, FeatureView, List[Union[FeatureView, Entity]]]
):
"""Register objects to metadata store and update related infrastructure.

The apply method registers one or more definitions (e.g., Entity, FeatureView) and registers or updates these
Expand Down Expand Up @@ -209,6 +211,8 @@ def apply(self, objects: List[Union[FeatureView, Entity]]):
# TODO: Add locking
# TODO: Optimize by only making a single call (read/write)

if isinstance(objects, Entity) or isinstance(objects, FeatureView):
objects = [objects]
views_to_update = []
for ob in objects:
if isinstance(ob, FeatureView):
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/test_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def test_apply_entity_success(test_feature_store):
labels={"team": "matchmaking"},
)

# Register Entity with Core
test_feature_store.apply([entity])
# Register Entity
test_feature_store.apply(entity)

entities = test_feature_store.list_entities()

Expand All @@ -107,7 +107,7 @@ def test_apply_entity_integration(test_feature_store):
labels={"team": "matchmaking"},
)

# Register Entity with Core
# Register Entity
test_feature_store.apply([entity])

entities = test_feature_store.list_entities()
Expand Down