Skip to content

Commit

Permalink
Make entity description optional and fix empty table_ref (#1425)
Browse files Browse the repository at this point in the history
* Make entity description optional and fix empty table_ref

Signed-off-by: Jacob Klegar <jacob@tecton.ai>

* Remove empty descriptions

Signed-off-by: Jacob Klegar <jacob@tecton.ai>

* fix lint

Signed-off-by: Jacob Klegar <jacob@tecton.ai>
  • Loading branch information
jklegar committed Mar 31, 2021
1 parent dd81448 commit ae477dd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sdk/python/feast/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def to_proto(self) -> DataSourceProto:

def get_table_query_string(self) -> str:
"""Returns a string that can directly be used to reference this table in SQL"""
if self.table_ref is not None:
if self.table_ref:
return f"`{self.table_ref}`"
else:
return f"({self.query})"
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Entity:
def __init__(
self,
name: str,
description: str,
value_type: ValueType,
description: str = "",
labels: Optional[MutableMapping[str, str]] = None,
):
self._name = name
Expand Down
5 changes: 1 addition & 4 deletions sdk/python/feast/offline_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ def pull_latest_from_table_or_query(
end_date: datetime,
) -> pyarrow.Table:
assert isinstance(data_source, BigQuerySource)
if data_source.table_ref:
from_expression = f"`{data_source.table_ref}`"
else:
from_expression = f"({data_source.query})"
from_expression = data_source.get_table_query_string()

partition_by_entity_string = ", ".join(entity_names)
if partition_by_entity_string != "":
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/online_write_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def benchmark_writes():
# This is just to set data source to something, we're not reading from parquet source here.
parquet_path = os.path.join(temp_dir, "data.parquet")

driver = Entity(name="driver_id", value_type=ValueType.INT64, description="")
driver = Entity(name="driver_id", value_type=ValueType.INT64)
table = create_driver_hourly_stats_feature_view(
create_driver_hourly_stats_source(parquet_path=parquet_path)
)
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/tests/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ def test_entity_without_labels_empty_dict():
entity = Entity("my-entity", description="My entity", value_type=ValueType.STRING)
assert entity.labels == dict()
assert len(entity.labels) == 0


def test_entity_without_description():
Entity("my-entity", value_type=ValueType.STRING)
8 changes: 4 additions & 4 deletions sdk/python/tests/test_historical_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def test_historical_features_from_parquet_sources():
temp_dir, customer_df
)
customer_fv = create_customer_daily_profile_feature_view(customer_source)
driver = Entity(name="driver", value_type=ValueType.INT64, description="")
customer = Entity(name="customer", value_type=ValueType.INT64, description="")
driver = Entity(name="driver", value_type=ValueType.INT64)
customer = Entity(name="customer", value_type=ValueType.INT64)

store = FeatureStore(
config=RepoConfig(
Expand Down Expand Up @@ -326,8 +326,8 @@ def test_historical_features_from_bigquery_sources():
)
customer_fv = create_customer_daily_profile_feature_view(customer_source)

driver = Entity(name="driver", value_type=ValueType.INT64, description="")
customer = Entity(name="customer", value_type=ValueType.INT64, description="")
driver = Entity(name="driver", value_type=ValueType.INT64)
customer = Entity(name="customer", value_type=ValueType.INT64)

store = FeatureStore(
config=RepoConfig(
Expand Down

0 comments on commit ae477dd

Please sign in to comment.