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

Add feature and feature set labels, for metadata #536

Merged
merged 25 commits into from
Apr 30, 2020
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e2d731c
Add labels column to feature field
imjuanleonard Mar 22, 2020
0cdb63b
Add labels to feature spec proto
imjuanleonard Mar 22, 2020
6802e0a
Implement labels on feature model
imjuanleonard Mar 22, 2020
60e4cc8
Implement list labels
imjuanleonard Mar 22, 2020
b597799
Implement set_label and remove_label from feature client
imjuanleonard Mar 22, 2020
4e69b2e
Refactor ingest to only accept featureset and dtype
imjuanleonard Mar 22, 2020
258560c
Add equality on labels field
imjuanleonard Mar 24, 2020
ced6609
Add tests for labels apply
imjuanleonard Mar 24, 2020
1a06833
Add Optional type hint to labels
imjuanleonard Mar 30, 2020
9e768a1
Add empty labels key validation
imjuanleonard Mar 30, 2020
108de14
Add label when generating feature spec for specServiceTest to test eq…
imjuanleonard Apr 1, 2020
c6cf42c
corrected convention (push test)
Apr 24, 2020
b9fd9af
corrected review comments
Apr 26, 2020
f241a4f
Merge branch 'master' into python-sdk-for-labels
Apr 27, 2020
dd88b6c
corrected lint-python check
Apr 27, 2020
2f7c86a
corrected lint-python 2
Apr 27, 2020
30d63fa
back out python SDK changes
Apr 28, 2020
4b7ec66
Implemented labels on a feature set level
Apr 28, 2020
b3a6317
added empty keys validation
Apr 28, 2020
de1153e
corrected review comments (storing empty json for features if labels …
Apr 29, 2020
a756929
Updated the comment to match the logic
suwik Apr 29, 2020
18edc12
added e2e tests for feature and feature set labels
Apr 30, 2020
5e10c94
Merge branch 'python-sdk-for-labels' of https://github.com/imjuanleon…
Apr 30, 2020
02197f8
moved e2e tests for feature and feature set labels
Apr 30, 2020
8d6d4f4
changed tests ordering
Apr 30, 2020
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
90 changes: 90 additions & 0 deletions tests/e2e/grpc-based-registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import pytest
import grpc
import uuid

import feast.core.CoreService_pb2
from feast import Feature
from feast.core.CoreService_pb2_grpc import CoreServiceStub
from feast.feature_set import FeatureSet
from feast import ValueType

PROJECT_NAME = 'batch_' + uuid.uuid4().hex.upper()[0:6]
LAST_VERSION = 0
GRPC_CONNECTION_TIMEOUT = 3
LABEL_KEY = "my"
LABEL_VALUE = "label"


Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests look good, but possibly add a TODO to migrate this over to the python sdk once that has been updated?

@pytest.fixture(scope="module")
def core_url(pytestconfig):
return pytestconfig.getoption("core_url")


@pytest.fixture(scope="module")
def core_service_stub(core_url):
if core_url.endswith(":443"):
core_channel = grpc.secure_channel(
core_url, grpc.ssl_channel_credentials()
)
else:
core_channel = grpc.insecure_channel(core_url)

try:
grpc.channel_ready_future(core_channel).result(timeout=GRPC_CONNECTION_TIMEOUT)
except grpc.FutureTimeoutError:
raise ConnectionError(
f"Connection timed out while attempting to connect to Feast "
f"Core gRPC server {core_url} "
)
core_service_stub = CoreServiceStub(core_channel)
return core_service_stub


def apply_feature_set(core_service_stub, feature_set_proto):
try:
apply_fs_response = core_service_stub.ApplyFeatureSet(
feast.core.CoreService_pb2.ApplyFeatureSetRequest(feature_set=feature_set_proto),
timeout=GRPC_CONNECTION_TIMEOUT,
) # type: ApplyFeatureSetResponse
except grpc.RpcError as e:
raise grpc.RpcError(e.details())
return apply_fs_response.feature_set


def get_feature_set(core_service_stub, name, project):
try:
get_feature_set_response = core_service_stub.GetFeatureSet(
feast.core.CoreService_pb2.GetFeatureSetRequest(
project=project, name=name.strip(), version=LAST_VERSION
)
) # type: GetFeatureSetResponse
except grpc.RpcError as e:
raise grpc.RpcError(e.details())
return get_feature_set_response.feature_set


@pytest.mark.timeout(45)
def test_feature_set_labels(core_service_stub):
feature_set_name = "test_feature_set_labels"
feature_set_proto = FeatureSet(feature_set_name, PROJECT_NAME).to_proto()
feature_set_proto.spec.labels[LABEL_KEY] = LABEL_VALUE
apply_feature_set(core_service_stub, feature_set_proto)

retrieved_feature_set = get_feature_set(core_service_stub, feature_set_name, PROJECT_NAME)

assert LABEL_KEY in retrieved_feature_set.spec.labels
assert retrieved_feature_set.spec.labels[LABEL_KEY] == LABEL_VALUE


def test_feature_labels(core_service_stub):
feature_set_name = "test_feature_labels"
feature_set_proto = FeatureSet(feature_set_name, PROJECT_NAME, features=[Feature("rating", ValueType.INT64)])\
.to_proto()
feature_set_proto.spec.features[0].labels[LABEL_KEY] = LABEL_VALUE
apply_feature_set(core_service_stub, feature_set_proto)

retrieved_feature_set = get_feature_set(core_service_stub, feature_set_name, PROJECT_NAME)
retrieved_feature = retrieved_feature_set.spec.features[0]

assert LABEL_KEY in retrieved_feature.labels
assert retrieved_feature.labels[LABEL_KEY] == LABEL_VALUE