Skip to content

Commit 29d9929

Browse files
feat: Renaming OnDemandTransformations to Transformations
Signed-off-by: Francisco Javier Arceo <franciscojavierarceo@users.noreply.github.com>
1 parent 6748fe7 commit 29d9929

File tree

7 files changed

+34
-49
lines changed

7 files changed

+34
-49
lines changed

sdk/python/feast/on_demand_feature_view.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from feast.feature_view import FeatureView
1818
from feast.feature_view_projection import FeatureViewProjection
1919
from feast.field import Field, from_value_type
20-
from feast.on_demand_pandas_transformation import OnDemandPandasTransformation
21-
from feast.on_demand_substrait_transformation import OnDemandSubstraitTransformation
2220
from feast.protos.feast.core.OnDemandFeatureView_pb2 import (
2321
OnDemandFeatureView as OnDemandFeatureViewProto,
2422
)
@@ -33,6 +31,8 @@
3331
from feast.protos.feast.core.Transformation_pb2 import (
3432
UserDefinedFunctionV2 as UserDefinedFunctionProto,
3533
)
34+
from feast.transformation.pandas_transformation import PandasTransformation
35+
from feast.transformation.substrait_transformation import SubstraitTransformation
3636
from feast.type_map import (
3737
feast_value_type_to_pandas_type,
3838
python_type_to_feast_value_type,
@@ -68,8 +68,8 @@ class OnDemandFeatureView(BaseFeatureView):
6868
features: List[Field]
6969
source_feature_view_projections: Dict[str, FeatureViewProjection]
7070
source_request_sources: Dict[str, RequestSource]
71-
transformation: Union[OnDemandPandasTransformation]
72-
feature_transformation: Union[OnDemandPandasTransformation]
71+
transformation: Union[PandasTransformation]
72+
feature_transformation: Union[PandasTransformation]
7373
description: str
7474
tags: Dict[str, str]
7575
owner: str
@@ -89,8 +89,8 @@ def __init__( # noqa: C901
8989
],
9090
udf: Optional[FunctionType] = None,
9191
udf_string: str = "",
92-
transformation: Optional[Union[OnDemandPandasTransformation]] = None,
93-
feature_transformation: Optional[Union[OnDemandPandasTransformation]] = None,
92+
transformation: Optional[Union[PandasTransformation]] = None,
93+
feature_transformation: Optional[Union[PandasTransformation]] = None,
9494
description: str = "",
9595
tags: Optional[Dict[str, str]] = None,
9696
owner: str = "",
@@ -129,7 +129,7 @@ def __init__( # noqa: C901
129129
"udf and udf_string parameters are deprecated. Please use transformation=OnDemandPandasTransformation(udf, udf_string) instead.",
130130
DeprecationWarning,
131131
)
132-
transformation = OnDemandPandasTransformation(udf, udf_string)
132+
transformation = PandasTransformation(udf, udf_string)
133133
else:
134134
raise Exception(
135135
"OnDemandFeatureView needs to be initialized with either transformation or udf arguments"
@@ -219,10 +219,10 @@ def to_proto(self) -> OnDemandFeatureViewProto:
219219

220220
feature_transformation = FeatureTransformationProto(
221221
user_defined_function=self.transformation.to_proto()
222-
if type(self.transformation) == OnDemandPandasTransformation
222+
if type(self.transformation) == PandasTransformation
223223
else None,
224224
on_demand_substrait_transformation=self.transformation.to_proto()
225-
if type(self.transformation) == OnDemandSubstraitTransformation
225+
if type(self.transformation) == SubstraitTransformation
226226
else None, # type: ignore
227227
)
228228
spec = OnDemandFeatureViewSpec(
@@ -276,7 +276,7 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
276276
and on_demand_feature_view_proto.spec.feature_transformation.user_defined_function.body_text
277277
!= ""
278278
):
279-
transformation = OnDemandPandasTransformation.from_proto(
279+
transformation = PandasTransformation.from_proto(
280280
on_demand_feature_view_proto.spec.feature_transformation.user_defined_function
281281
)
282282
elif (
@@ -285,7 +285,7 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
285285
)
286286
== "on_demand_substrait_transformation"
287287
):
288-
transformation = OnDemandSubstraitTransformation.from_proto(
288+
transformation = SubstraitTransformation.from_proto(
289289
on_demand_feature_view_proto.spec.feature_transformation.on_demand_substrait_transformation
290290
)
291291
elif (
@@ -298,7 +298,7 @@ def from_proto(cls, on_demand_feature_view_proto: OnDemandFeatureViewProto):
298298
body=on_demand_feature_view_proto.spec.user_defined_function.body,
299299
body_text=on_demand_feature_view_proto.spec.user_defined_function.body_text,
300300
)
301-
transformation = OnDemandPandasTransformation.from_proto(
301+
transformation = PandasTransformation.from_proto(
302302
user_defined_function_proto=backwards_compatible_udf,
303303
)
304304
else:
@@ -540,13 +540,13 @@ def decorator(user_function):
540540

541541
expr = user_function(ibis.table(input_fields, "t"))
542542

543-
transformation = OnDemandSubstraitTransformation(
543+
transformation = SubstraitTransformation(
544544
substrait_plan=compiler.compile(expr).SerializeToString()
545545
)
546546
else:
547547
udf_string = dill.source.getsource(user_function)
548548
mainify(user_function)
549-
transformation = OnDemandPandasTransformation(user_function, udf_string)
549+
transformation = PandasTransformation(user_function, udf_string)
550550

551551
on_demand_feature_view_obj = OnDemandFeatureView(
552552
name=user_function.__name__,

sdk/python/feast/stream_feature_view.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from feast.entity import Entity
1616
from feast.feature_view import FeatureView
1717
from feast.field import Field
18-
from feast.on_demand_pandas_transformation import OnDemandPandasTransformation
1918
from feast.protos.feast.core.DataSource_pb2 import DataSource as DataSourceProto
2019
from feast.protos.feast.core.OnDemandFeatureView_pb2 import (
2120
UserDefinedFunction as UserDefinedFunctionProto,
@@ -32,6 +31,7 @@
3231
from feast.protos.feast.core.Transformation_pb2 import (
3332
UserDefinedFunctionV2 as UserDefinedFunctionProtoV2,
3433
)
34+
from feast.transformation.pandas_transformation import PandasTransformation
3535

3636
warnings.simplefilter("once", RuntimeWarning)
3737

@@ -80,7 +80,7 @@ class StreamFeatureView(FeatureView):
8080
materialization_intervals: List[Tuple[datetime, datetime]]
8181
udf: Optional[FunctionType]
8282
udf_string: Optional[str]
83-
feature_transformation: Optional[OnDemandPandasTransformation]
83+
feature_transformation: Optional[PandasTransformation]
8484

8585
def __init__(
8686
self,
@@ -99,7 +99,7 @@ def __init__(
9999
timestamp_field: Optional[str] = "",
100100
udf: Optional[FunctionType] = None,
101101
udf_string: Optional[str] = "",
102-
feature_transformation: Optional[Union[OnDemandPandasTransformation]] = None,
102+
feature_transformation: Optional[Union[PandasTransformation]] = None,
103103
):
104104
if not flags_helper.is_test():
105105
warnings.warn(
@@ -371,9 +371,7 @@ def decorator(user_function):
371371
schema=schema,
372372
udf=user_function,
373373
udf_string=udf_string,
374-
feature_transformation=OnDemandPandasTransformation(
375-
user_function, udf_string
376-
),
374+
feature_transformation=PandasTransformation(user_function, udf_string),
377375
description=description,
378376
tags=tags,
379377
online=online,

sdk/python/feast/transformation/__init__.py

Whitespace-only changes.

sdk/python/feast/on_demand_pandas_transformation.py renamed to sdk/python/feast/transformation/pandas_transformation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99

1010

11-
class OnDemandPandasTransformation:
11+
class PandasTransformation:
1212
def __init__(self, udf: FunctionType, udf_string: str = ""):
1313
"""
1414
Creates an OnDemandPandasTransformation object.
@@ -25,7 +25,7 @@ def transform(self, df: pd.DataFrame) -> pd.DataFrame:
2525
return self.udf.__call__(df)
2626

2727
def __eq__(self, other):
28-
if not isinstance(other, OnDemandPandasTransformation):
28+
if not isinstance(other, PandasTransformation):
2929
raise TypeError(
3030
"Comparisons should only involve OnDemandPandasTransformation class objects."
3131
)
@@ -47,7 +47,7 @@ def to_proto(self) -> UserDefinedFunctionProto:
4747

4848
@classmethod
4949
def from_proto(cls, user_defined_function_proto: UserDefinedFunctionProto):
50-
return OnDemandPandasTransformation(
50+
return PandasTransformation(
5151
udf=dill.loads(user_defined_function_proto.body),
5252
udf_string=user_defined_function_proto.body_text,
5353
)

sdk/python/feast/on_demand_substrait_transformation.py renamed to sdk/python/feast/transformation/substrait_transformation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)
88

99

10-
class OnDemandSubstraitTransformation:
10+
class SubstraitTransformation:
1111
def __init__(self, substrait_plan: bytes):
1212
"""
1313
Creates an OnDemandSubstraitTransformation object.
@@ -27,7 +27,7 @@ def table_provider(names, schema: pyarrow.Schema):
2727
return table.to_pandas()
2828

2929
def __eq__(self, other):
30-
if not isinstance(other, OnDemandSubstraitTransformation):
30+
if not isinstance(other, SubstraitTransformation):
3131
raise TypeError(
3232
"Comparisons should only involve OnDemandSubstraitTransformation class objects."
3333
)
@@ -45,6 +45,6 @@ def from_proto(
4545
cls,
4646
on_demand_substrait_transformation_proto: OnDemandSubstraitTransformationProto,
4747
):
48-
return OnDemandSubstraitTransformation(
48+
return SubstraitTransformation(
4949
substrait_plan=on_demand_substrait_transformation_proto.substrait_plan
5050
)

sdk/python/tests/integration/feature_repos/universal/feature_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
)
1616
from feast.data_source import DataSource, RequestSource
1717
from feast.feature_view_projection import FeatureViewProjection
18-
from feast.on_demand_feature_view import OnDemandPandasTransformation
18+
from feast.on_demand_feature_view import PandasTransformation
1919
from feast.types import Array, FeastType, Float32, Float64, Int32, Int64
2020
from tests.integration.feature_repos.universal.entities import (
2121
customer,
@@ -71,7 +71,7 @@ def conv_rate_plus_100_feature_view(
7171
name=conv_rate_plus_100.__name__,
7272
schema=[] if infer_features else _features,
7373
sources=sources,
74-
transformation=OnDemandPandasTransformation(
74+
transformation=PandasTransformation(
7575
udf=conv_rate_plus_100, udf_string="raw udf source"
7676
),
7777
)
@@ -110,7 +110,7 @@ def similarity_feature_view(
110110
name=similarity.__name__,
111111
sources=sources,
112112
schema=[] if infer_features else _fields,
113-
transformation=OnDemandPandasTransformation(
113+
transformation=PandasTransformation(
114114
udf=similarity, udf_string="similarity raw udf"
115115
),
116116
)

sdk/python/tests/unit/test_on_demand_feature_view.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
from feast.feature_view import FeatureView
1919
from feast.field import Field
2020
from feast.infra.offline_stores.file_source import FileSource
21-
from feast.on_demand_feature_view import (
22-
OnDemandFeatureView,
23-
OnDemandPandasTransformation,
24-
)
21+
from feast.on_demand_feature_view import OnDemandFeatureView, PandasTransformation
2522
from feast.types import Float32
2623

2724

@@ -59,9 +56,7 @@ def test_hash():
5956
Field(name="output1", dtype=Float32),
6057
Field(name="output2", dtype=Float32),
6158
],
62-
transformation=OnDemandPandasTransformation(
63-
udf=udf1, udf_string="udf1 source code"
64-
),
59+
transformation=PandasTransformation(udf=udf1, udf_string="udf1 source code"),
6560
)
6661
on_demand_feature_view_2 = OnDemandFeatureView(
6762
name="my-on-demand-feature-view",
@@ -70,9 +65,7 @@ def test_hash():
7065
Field(name="output1", dtype=Float32),
7166
Field(name="output2", dtype=Float32),
7267
],
73-
transformation=OnDemandPandasTransformation(
74-
udf=udf1, udf_string="udf1 source code"
75-
),
68+
transformation=PandasTransformation(udf=udf1, udf_string="udf1 source code"),
7669
)
7770
on_demand_feature_view_3 = OnDemandFeatureView(
7871
name="my-on-demand-feature-view",
@@ -81,9 +74,7 @@ def test_hash():
8174
Field(name="output1", dtype=Float32),
8275
Field(name="output2", dtype=Float32),
8376
],
84-
transformation=OnDemandPandasTransformation(
85-
udf=udf2, udf_string="udf2 source code"
86-
),
77+
transformation=PandasTransformation(udf=udf2, udf_string="udf2 source code"),
8778
)
8879
on_demand_feature_view_4 = OnDemandFeatureView(
8980
name="my-on-demand-feature-view",
@@ -92,9 +83,7 @@ def test_hash():
9283
Field(name="output1", dtype=Float32),
9384
Field(name="output2", dtype=Float32),
9485
],
95-
transformation=OnDemandPandasTransformation(
96-
udf=udf2, udf_string="udf2 source code"
97-
),
86+
transformation=PandasTransformation(udf=udf2, udf_string="udf2 source code"),
9887
description="test",
9988
)
10089
on_demand_feature_view_5 = OnDemandFeatureView(
@@ -126,7 +115,7 @@ def test_hash():
126115
}
127116
assert len(s4) == 3
128117

129-
assert on_demand_feature_view_5.transformation == OnDemandPandasTransformation(
118+
assert on_demand_feature_view_5.transformation == PandasTransformation(
130119
udf2, "udf2 source code"
131120
)
132121
assert (
@@ -155,9 +144,7 @@ def test_from_proto_backwards_compatable_udf():
155144
Field(name="output1", dtype=Float32),
156145
Field(name="output2", dtype=Float32),
157146
],
158-
transformation=OnDemandPandasTransformation(
159-
udf=udf1, udf_string="udf1 source code"
160-
),
147+
transformation=PandasTransformation(udf=udf1, udf_string="udf1 source code"),
161148
)
162149

163150
# We need a proto with the "udf1 source code" in the user_defined_function.body_text

0 commit comments

Comments
 (0)