Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with numpy datetimes in feast_value_type_to_pandas_type #2167

Merged
merged 1 commit into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sdk/python/feast/on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def get_requested_odfvs(feature_refs, project, registry):
return requested_on_demand_feature_views


def on_demand_feature_view(features: List[Feature], inputs: Dict[str, FeatureView]):
def on_demand_feature_view(
features: List[Feature], inputs: Dict[str, Union[FeatureView, RequestDataSource]]
):
"""
Declare an on-demand feature view

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def feast_value_type_to_pandas_type(value_type: ValueType) -> Any:
ValueType.DOUBLE: "float",
ValueType.BYTES: "bytes",
ValueType.BOOL: "bool",
ValueType.UNIX_TIMESTAMP: "datetime",
ValueType.UNIX_TIMESTAMP: "datetime64[ns]",
}
if value_type.name.endswith("_LIST"):
return "object"
Expand Down
23 changes: 22 additions & 1 deletion sdk/python/tests/integration/registration/test_inference.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import pandas as pd
import pytest

from feast import Entity, RepoConfig, ValueType
from feast import Entity, Feature, RepoConfig, ValueType
from feast.data_source import RequestDataSource
from feast.errors import RegistryInferenceFailure
from feast.feature_view import FeatureView
from feast.inference import (
update_data_sources_with_inferred_event_timestamp_col,
update_entities_with_inferred_types_from_feature_views,
)
from feast.on_demand_feature_view import on_demand_feature_view
from tests.utils.data_source_utils import (
prep_file_source,
simple_bq_source_using_query_arg,
Expand Down Expand Up @@ -81,3 +84,21 @@ def test_update_data_sources_with_inferred_event_timestamp_col(simple_dataset_1)
update_data_sources_with_inferred_event_timestamp_col(
[file_source], RepoConfig(provider="local", project="test")
)


def test_modify_feature_views_success():
# Create Feature Views
date_request = RequestDataSource(
name="date_request", schema={"some_date": ValueType.UNIX_TIMESTAMP}
)

@on_demand_feature_view(
inputs={"date_request": date_request},
features=[Feature("output", ValueType.UNIX_TIMESTAMP)],
)
def test_view(features_df: pd.DataFrame) -> pd.DataFrame:
data = pd.DataFrame()
data["output"] = features_df["some_date"]
return data

test_view.infer_features()