Skip to content

Commit

Permalink
back out python SDK changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Suwinski committed Apr 28, 2020
1 parent 2f7c86a commit 30d63fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 52 deletions.
14 changes: 0 additions & 14 deletions sdk/python/feast/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def to_proto(self) -> FeatureProto:
url_domain=self.url_domain,
time_domain=self.time_domain,
time_of_day_domain=self.time_of_day_domain,
labels=self.labels,
)

@classmethod
Expand All @@ -59,21 +58,8 @@ def from_proto(cls, feature_proto: FeatureProto):
feature = cls(
name=feature_proto.name,
dtype=ValueType(feature_proto.value_type),
labels=feature_proto.labels,
)
feature.update_presence_constraints(feature_proto)
feature.update_shape_type(feature_proto)
feature.update_domain_info(feature_proto)
return feature

def set_label(self, key, value):
"""
Set label for feature
"""
self._labels[key] = value

def remove_label(self, key):
"""
Remove label for a feature
"""
del self._labels[key]
21 changes: 2 additions & 19 deletions sdk/python/feast/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Union
from typing import Dict, Optional

from feast.core.FeatureSet_pb2 import EntitySpec, FeatureSpec
from feast.value_type import ValueType
Expand All @@ -25,7 +24,7 @@ class Field:
features.
"""

def __init__(self, name: str, dtype: ValueType, labels: Optional[Dict] = None):
def __init__(self, name: str, dtype: ValueType):
self._name = name
if not isinstance(dtype, ValueType):
raise ValueError("dtype is not a valid ValueType")
Expand All @@ -46,17 +45,9 @@ def __init__(self, name: str, dtype: ValueType, labels: Optional[Dict] = None):
self._url_domain = None
self._time_domain = None
self._time_of_day_domain = None
if labels is None:
self._labels = dict()
else:
self._labels = labels

def __eq__(self, other):
if (
self.name != other.name
or self.dtype != other.dtype
or self.labels != other.labels
):
if self.name != other.name or self.dtype != other.dtype:
return False
return True

Expand Down Expand Up @@ -422,14 +413,6 @@ def update_domain_info(
elif domain_info_case == "time_of_day_domain":
self.time_of_day_domain = feature.time_of_day_domain

@property
def labels(self):
"""
Getter for labels of this filed
"""

return self._labels

def to_proto(self):
"""
Unimplemented to_proto method for a field. This should be extended.
Expand Down
22 changes: 3 additions & 19 deletions sdk/python/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,24 +538,12 @@ def test_apply_feature_set_success(self, test_client):

# Create Feature Sets
fs1 = FeatureSet("my-feature-set-1")
fs1.add(
Feature(
name="fs1-my-feature-1",
dtype=ValueType.INT64,
labels={"fs1": "feature_1", "fs1_2": "feature_1"},
)
)
fs1_f2 = Feature(name="fs1-my-feature-2", dtype=ValueType.STRING)
fs1_f2.set_label("fs1", "feature_2")
fs1.add(fs1_f2)
fs1.add(Feature(name="fs1-my-feature-1", dtype=ValueType.INT64))
fs1.add(Feature(name="fs1-my-feature-2", dtype=ValueType.STRING))
fs1.add(Entity(name="fs1-my-entity-1", dtype=ValueType.INT64))

fs2 = FeatureSet("my-feature-set-2")
fs2_f1 = Feature(name="fs2-my-feature-1", dtype=ValueType.STRING_LIST)
fs2_f1.set_label("fs2", "feature_1")
fs2_f1.set_label("fs3", "feature_1")
fs2_f1.remove_label("fs3")
fs2.add(fs2_f1)
fs2.add(Feature(name="fs2-my-feature-1", dtype=ValueType.STRING_LIST))
fs2.add(Feature(name="fs2-my-feature-2", dtype=ValueType.BYTES_LIST))
fs2.add(Entity(name="fs2-my-entity-1", dtype=ValueType.INT64))

Expand All @@ -571,16 +559,12 @@ def test_apply_feature_set_success(self, test_client):
and feature_sets[0].name == "my-feature-set-1"
and feature_sets[0].features[0].name == "fs1-my-feature-1"
and feature_sets[0].features[0].dtype == ValueType.INT64
and feature_sets[0].features[0].labels
== {"fs1": "feature_1", "fs1_2": "feature_1"}
and feature_sets[0].features[1].name == "fs1-my-feature-2"
and feature_sets[0].features[1].dtype == ValueType.STRING
and feature_sets[0].features[1].labels == {"fs1": "feature_2"}
and feature_sets[0].entities[0].name == "fs1-my-entity-1"
and feature_sets[0].entities[0].dtype == ValueType.INT64
and feature_sets[1].features[0].name == "fs2-my-feature-1"
and feature_sets[1].features[0].dtype == ValueType.STRING_LIST
and feature_sets[1].features[0].labels == {"fs2": "feature_1"}
and feature_sets[1].features[1].name == "fs2-my-feature-2"
and feature_sets[1].features[1].dtype == ValueType.BYTES_LIST
and feature_sets[1].entities[0].name == "fs2-my-entity-1"
Expand Down

0 comments on commit 30d63fa

Please sign in to comment.