Skip to content
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: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ The list below contains the functionality that contributors are planning to deve
* [x] Python Client
* [x] [Python feature server](https://docs.feast.dev/reference/feature-servers/python-feature-server)
* [x] [Java feature server (alpha)](https://github.com/feast-dev/feast/blob/master/infra/charts/feast/README.md)
* [x] [Go feature server (alpha)](https://github.com/feast-dev/feast/blob/master/go/README.md)
* [x] [Go feature server (alpha)](https://docs.feast.dev/reference/feature-servers/go-feature-server)
* **Data Quality Management (See [RFC](https://docs.google.com/document/d/110F72d4NTv80p35wDSONxhhPBqWRwbZXG4f9mNEMd98/edit))**
* [x] Data profiling and validation (Great Expectations)
* **Feature Discovery and Governance**
Expand Down Expand Up @@ -249,4 +249,4 @@ Thanks goes to these incredible people:

<a href="https://github.com/feast-dev/feast/graphs/contributors">
<img src="https://contrib.rocks/image?repo=feast-dev/feast" />
</a>
</a>
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 @@ -722,6 +722,7 @@ def get_requested_odfvs(

def on_demand_feature_view(
*,
name: Optional[str] = None,
entities: Optional[List[Entity]] = None,
schema: list[Field],
sources: list[
Expand All @@ -742,6 +743,7 @@ def on_demand_feature_view(
Creates an OnDemandFeatureView object with the given user function as udf.

Args:
name (optional): The name of the on demand feature view. If not provided, the name will be the name of the user function.
entities (Optional): The list of names of entities that this feature view is associated with.
schema: The list of features in the output of the on demand feature view, after
the transformation has been applied.
Expand Down Expand Up @@ -791,7 +793,7 @@ def decorator(user_function):
transformation = SubstraitTransformation.from_ibis(user_function, sources)

on_demand_feature_view_obj = OnDemandFeatureView(
name=user_function.__name__,
name=name if name is not None else user_function.__name__,
sources=sources,
schema=schema,
feature_transformation=transformation,
Expand Down
63 changes: 63 additions & 0 deletions sdk/python/tests/unit/test_on_demand_feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OnDemandFeatureView,
PandasTransformation,
PythonTransformation,
on_demand_feature_view,
)
from feast.types import Float32

Expand Down Expand Up @@ -356,3 +357,65 @@ def test_on_demand_feature_view_stored_writes():
assert transformed_output["output3"] is not None and isinstance(
transformed_output["output3"], datetime.datetime
)


def test_function_call_syntax():
CUSTOM_FUNCTION_NAME = "custom-function-name"
file_source = FileSource(name="my-file-source", path="test.parquet")
feature_view = FeatureView(
name="my-feature-view",
entities=[],
schema=[
Field(name="feature1", dtype=Float32),
Field(name="feature2", dtype=Float32),
],
source=file_source,
)
sources = [feature_view]

def transform_features(features_df: pd.DataFrame) -> pd.DataFrame:
df = pd.DataFrame()
df["output1"] = features_df["feature1"]
df["output2"] = features_df["feature2"]
return df

odfv = on_demand_feature_view(
sources=sources,
schema=[
Field(name="output1", dtype=Float32),
Field(name="output2", dtype=Float32),
],
)(transform_features)

assert odfv.name == transform_features.__name__
assert isinstance(odfv, OnDemandFeatureView)

proto = odfv.to_proto()
assert proto.spec.name == transform_features.__name__

deserialized = OnDemandFeatureView.from_proto(proto)
assert deserialized.name == transform_features.__name__

def another_transform(features_df: pd.DataFrame) -> pd.DataFrame:
df = pd.DataFrame()
df["output1"] = features_df["feature1"]
df["output2"] = features_df["feature2"]
return df

odfv_custom = on_demand_feature_view(
name=CUSTOM_FUNCTION_NAME,
sources=sources,
schema=[
Field(name="output1", dtype=Float32),
Field(name="output2", dtype=Float32),
],
)(another_transform)

assert odfv_custom.name == CUSTOM_FUNCTION_NAME
assert isinstance(odfv_custom, OnDemandFeatureView)

proto = odfv_custom.to_proto()
assert proto.spec.name == CUSTOM_FUNCTION_NAME

deserialized = OnDemandFeatureView.from_proto(proto)
assert deserialized.name == CUSTOM_FUNCTION_NAME
Loading