Skip to content
Prev Previous commit
Next Next commit
Fix
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
  • Loading branch information
kevjumba committed Apr 21, 2022
commit 27b7b6e40c93c27980cfa263f4b46dd615177621
40 changes: 25 additions & 15 deletions sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ def __init__(
),
DeprecationWarning,
)

_sources = sources or inputs
_sources = sources or []
if inputs and sources:
raise ValueError("At most one of `sources` or `inputs` can be specified.")
elif inputs:
Expand All @@ -137,7 +136,8 @@ def __init__(
),
DeprecationWarning,
)

for source in inputs.values():
_sources.append(source)
_udf = udf

if args:
Expand Down Expand Up @@ -171,7 +171,9 @@ def __init__(
DeprecationWarning,
)
if len(args) >= 3:
_sources = args[2]
_inputs = args[2]
for source in _inputs.values():
_sources.append(source)
warnings.warn(
(
"The `inputs` parameter is being deprecated. Please use `sources` instead. "
Expand All @@ -197,7 +199,8 @@ def __init__(
tags=tags,
owner=owner,
)

print("Asdf")
print(_sources)
assert _sources is not None
self.source_feature_view_projections: Dict[str, FeatureViewProjection] = {}
self.source_request_sources: Dict[str, RequestSource] = {}
Expand Down Expand Up @@ -304,23 +307,26 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
Returns:
A OnDemandFeatureView object based on the on-demand feature view protobuf.
"""
sources = {}
sources = []
for (
source_name,
_,
on_demand_source,
) in on_demand_feature_view_proto.spec.sources.items():
if on_demand_source.WhichOneof("source") == "feature_view":
sources[source_name] = FeatureView.from_proto(
sources.append(
FeatureView.from_proto(
on_demand_source.feature_view
).projection
).projection)
elif on_demand_source.WhichOneof("source") == "feature_view_projection":
sources[source_name] = FeatureViewProjection.from_proto(
sources.append(
FeatureViewProjection.from_proto(
on_demand_source.feature_view_projection
)
))
else:
sources[source_name] = RequestSource.from_proto(
sources.append(
RequestSource.from_proto(
on_demand_source.request_data_source
)
))
on_demand_feature_view_obj = cls(
name=on_demand_feature_view_proto.spec.name,
schema=[
Expand Down Expand Up @@ -520,7 +526,7 @@ def on_demand_feature_view(
DeprecationWarning,
)

_sources = sources or inputs
_sources = sources or []
if inputs and sources:
raise ValueError("At most one of `sources` or `inputs` can be specified.")
elif inputs:
Expand All @@ -531,6 +537,8 @@ def on_demand_feature_view(
),
DeprecationWarning,
)
for source in inputs.values():
_sources.append(source)

if args:
warnings.warn(
Expand Down Expand Up @@ -561,7 +569,9 @@ def on_demand_feature_view(
DeprecationWarning,
)
if len(args) >= 2:
_sources = args[1]
_inputs = args[1]
for source in _inputs.values():
_sources.append(source)
warnings.warn(
(
"The `inputs` parameter is being deprecated. Please use `sources` instead. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas as pd

from feast import (
BaseFeatureView,
Feature,
FeatureView,
Field,
Expand All @@ -14,7 +15,6 @@
)
from feast.data_source import DataSource, RequestSource
from feast.types import Array, FeastType, Float32, Float64, Int32
from sdk.python.feast.base_feature_view import BaseFeatureView
from tests.integration.feature_repos.universal.entities import location


Expand Down
8 changes: 4 additions & 4 deletions sdk/python/tests/integration/registration/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_on_demand_features_type_inference():
)

@on_demand_feature_view(
sources={"date_request": date_request},
sources=[date_request],
schema=[
Field(name="output", dtype=UnixTimestamp),
Field(name="string_output", dtype=String),
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_datasource_inference(request_source_schema):
Feature(name="output", dtype=ValueType.UNIX_TIMESTAMP),
Feature(name="string_output", dtype=ValueType.STRING),
],
sources={"date_request": date_request},
sources=[date_request],
)
def test_view(features_df: pd.DataFrame) -> pd.DataFrame:
data = pd.DataFrame()
Expand All @@ -256,7 +256,7 @@ def test_view(features_df: pd.DataFrame) -> pd.DataFrame:
test_view.infer_features()

@on_demand_feature_view(
sources={"date_request": date_request},
sources=[date_request],
schema=[
Field(name="output", dtype=UnixTimestamp),
Field(name="object_output", dtype=String),
Expand All @@ -272,7 +272,7 @@ def invalid_test_view(features_df: pd.DataFrame) -> pd.DataFrame:
invalid_test_view.infer_features()

@on_demand_feature_view(
sources={"date_request": date_request},
sources=[date_request],
features=[
Feature(name="output", dtype=ValueType.UNIX_TIMESTAMP),
Feature(name="missing", dtype=ValueType.STRING),
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/tests/integration/registration/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_modify_feature_views_success(test_registry, request_source_schema):
Feature(name="odfv1_my_feature_1", dtype=ValueType.STRING),
Feature(name="odfv1_my_feature_2", dtype=ValueType.INT32),
],
sources={"request_source": request_source},
sources=[request_source],
)
def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
data = pd.DataFrame()
Expand All @@ -287,7 +287,7 @@ def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
Feature(name="odfv1_my_feature_1", dtype=ValueType.FLOAT),
Feature(name="odfv1_my_feature_2", dtype=ValueType.INT32),
],
sources={"request_source": request_source},
sources=[request_source],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have a test that tests the Dict[str, Source] version to make sure that the changes are backwards compatibile?

)
def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
data = pd.DataFrame()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from feast.errors import SpecifiedFeaturesNotPresentError
from feast.infra.offline_stores.file_source import FileSource
from feast.types import Float64
from sdk.python.tests.integration.feature_repos.universal.feature_views import create_driver_hourly_stats_base_feature_view
from tests.integration.feature_repos.universal.entities import customer, driver, item
from tests.integration.feature_repos.universal.feature_views import (
conv_rate_plus_100_feature_view,
Expand Down