Skip to content

Commit 6304284

Browse files
authored
Add test to ensure saving and loading from registry is safe (feast-dev#1453)
Signed-off-by: Willem Pienaar <git@willem.co>
1 parent ec9c4fd commit 6304284

4 files changed

Lines changed: 299 additions & 200 deletions

File tree

sdk/python/feast/data_source.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,13 @@ def __eq__(self, other):
567567
if not isinstance(other, FileSource):
568568
raise TypeError("Comparisons should only involve FileSource class objects.")
569569

570-
if (
571-
self.file_options.file_url != other.file_options.file_url
572-
or self.file_options.file_format != other.file_options.file_format
573-
):
574-
return False
575-
return True
570+
return (
571+
self.file_options.file_url == other.file_options.file_url
572+
and self.file_options.file_format == other.file_options.file_format
573+
and self.event_timestamp_column == other.event_timestamp_column
574+
and self.created_timestamp_column == other.created_timestamp_column
575+
and self.field_mapping == other.field_mapping
576+
)
576577

577578
@property
578579
def file_options(self):
@@ -633,10 +634,13 @@ def __eq__(self, other):
633634
"Comparisons should only involve BigQuerySource class objects."
634635
)
635636

636-
if self.bigquery_options.table_ref != other.bigquery_options.table_ref:
637-
return False
638-
639-
return True
637+
return (
638+
self.bigquery_options.table_ref == other.bigquery_options.table_ref
639+
and self.bigquery_options.query == other.bigquery_options.query
640+
and self.event_timestamp_column == other.event_timestamp_column
641+
and self.created_timestamp_column == other.created_timestamp_column
642+
and self.field_mapping == other.field_mapping
643+
)
640644

641645
@property
642646
def table_ref(self):

sdk/python/feast/feature_view.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import Dict, List, Optional, Tuple, Union
1616

1717
from google.protobuf.duration_pb2 import Duration
18+
from google.protobuf.json_format import MessageToJson
1819
from google.protobuf.timestamp_pb2 import Timestamp
1920

2021
from feast import utils
@@ -82,6 +83,39 @@ def __init__(
8283

8384
self.materialization_intervals = []
8485

86+
def __repr__(self):
87+
items = (f"{k} = {v}" for k, v in self.__dict__.items())
88+
return f"<{self.__class__.__name__}({', '.join(items)})>"
89+
90+
def __str__(self):
91+
return str(MessageToJson(self.to_proto()))
92+
93+
def __hash__(self):
94+
return hash(self.name)
95+
96+
def __eq__(self, other):
97+
if not isinstance(other, FeatureView):
98+
raise TypeError(
99+
"Comparisons should only involve FeatureView class objects."
100+
)
101+
102+
if (
103+
self.tags != other.tags
104+
or self.name != other.name
105+
or self.ttl != other.ttl
106+
or self.online != other.online
107+
):
108+
return False
109+
110+
if sorted(self.entities) != sorted(other.entities):
111+
return False
112+
if sorted(self.features) != sorted(other.features):
113+
return False
114+
if self.input != other.input:
115+
return False
116+
117+
return True
118+
85119
def is_valid(self):
86120
"""
87121
Validates the state of a feature view locally. Raises an exception

sdk/python/feast/telemetry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def __init__(self):
5252

5353
@property
5454
def telemetry_id(self):
55-
if os.environ["FEAST_FORCE_TELEMETRY_UUID"]:
56-
return os.environ["FEAST_FORCE_TELEMETRY_UUID"]
55+
if os.getenv("FEAST_FORCE_TELEMETRY_UUID"):
56+
return os.getenv("FEAST_FORCE_TELEMETRY_UUID")
5757
return self._telemetry_id
5858

5959
def log(self, function_name: str):

0 commit comments

Comments
 (0)