Skip to content
Prev Previous commit
Next Next commit
Fix lint
Signed-off-by: Kevin Zhang <kzhang@tecton.ai>
  • Loading branch information
kevjumba committed Apr 21, 2022
commit f6ab5dae30132c5abfe21f8efdca3091b87b87fe
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def test_infer_odfv_features(environment, universal_data_sources, infer_features
)
request_source = create_conv_rate_request_source()
driver_odfv = conv_rate_plus_100_feature_view(
[driver_hourly_stats, request_source],
infer_features=infer_features,
[driver_hourly_stats, request_source], infer_features=infer_features,
)

feast_objects = [driver_hourly_stats, driver_odfv, driver(), customer()]
Expand Down Expand Up @@ -85,8 +84,7 @@ def test_infer_odfv_features_with_error(environment, universal_data_sources):
)
request_source = create_conv_rate_request_source()
driver_odfv = conv_rate_plus_100_feature_view(
[driver_hourly_stats, request_source],
features=features,
[driver_hourly_stats, request_source], features=features,
)

feast_objects = [driver_hourly_stats, driver_odfv, driver(), customer()]
Expand Down
14 changes: 9 additions & 5 deletions sdk/python/tests/unit/test_on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from datetime import date

import pandas as pd
import pytest

from feast import RequestSource
from feast.feature_view import FeatureView
from feast.field import Field
from feast.infra.offline_stores.file_source import FileSource
from feast import RequestSource
from feast.types import String, UnixTimestamp
from feast.on_demand_feature_view import OnDemandFeatureView, on_demand_feature_view
from feast.types import Float32
from feast.types import Float32, String, UnixTimestamp


def udf1(features_df: pd.DataFrame) -> pd.DataFrame:
Expand Down Expand Up @@ -104,11 +104,13 @@ def test_hash():
}
assert len(s4) == 3


def test_inputs_parameter_deprecation_in_odfv():
date_request = RequestSource(
name="date_request", schema=[Field(name="some_date", dtype=UnixTimestamp)],
)
with pytest.warns(DeprecationWarning):

@on_demand_feature_view(
inputs={"date_request": date_request},
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.

oh hah never mind, you have this test. Love it.

schema=[
Expand All @@ -121,13 +123,15 @@ def test_view(features_df: pd.DataFrame) -> pd.DataFrame:
data["output"] = features_df["some_date"]
data["string_output"] = features_df["some_date"].astype(pd.StringDtype())
return data

odfv = test_view
assert odfv.name == "test_view"
assert len(odfv.source_request_sources) == 1
assert odfv.source_request_sources["date_request"].name == "date_request"
assert odfv.source_request_sources["date_request"].schema == date_request.schema

with pytest.raises(ValueError):

@on_demand_feature_view(
inputs={"date_request": date_request},
sources=[date_request],
Expand All @@ -142,7 +146,6 @@ def incorrect_testview(features_df: pd.DataFrame) -> pd.DataFrame:
data["string_output"] = features_df["some_date"].astype(pd.StringDtype())
return data


@on_demand_feature_view(
inputs={"odfv": date_request},
schema=[
Expand All @@ -155,6 +158,7 @@ def test_correct_view(features_df: pd.DataFrame) -> pd.DataFrame:
data["output"] = features_df["some_date"]
data["string_output"] = features_df["some_date"].astype(pd.StringDtype())
return data

odfv = test_correct_view
assert odfv.name == "test_correct_view"
assert odfv.source_request_sources["date_request"].schema == date_request.schema