2020
2121from feast .feature_store import FeatureStore
2222from feast .on_demand_feature_view import PandasTransformation , PythonTransformation
23- from feast .protos .feast .core .Transformation_pb2 import UserDefinedFunctionV2 as UserDefinedFunctionProto
23+ from feast .protos .feast .core .Transformation_pb2 import (
24+ UserDefinedFunctionV2 as UserDefinedFunctionProto ,
25+ )
2426
2527
2628def test_apply_has_skip_feature_view_validation_parameter ():
@@ -93,32 +95,33 @@ def test_push_async_has_skip_validation_parameter():
9395
9496def test_pandas_transformation_from_proto_with_skip_udf ():
9597 """Test that PandasTransformation.from_proto works with skip_udf=True."""
96-
98+
9799 # Create a UDF that would reference a non-existent module
98100 def udf_with_missing_module (df : pd .DataFrame ) -> pd .DataFrame :
99101 # This would normally fail if a module is missing during deserialization
100102 import nonexistent_module # noqa: F401
103+
101104 return df
102-
105+
103106 # Serialize the UDF
104107 serialized_udf = dill .dumps (udf_with_missing_module )
105108 udf_string = "import nonexistent_module\n def udf(df): return df"
106-
109+
107110 # Create proto
108111 udf_proto = UserDefinedFunctionProto (
109112 name = "test_udf" ,
110113 body = serialized_udf ,
111114 body_text = udf_string ,
112115 )
113-
116+
114117 # Test that skip_udf=True doesn't try to deserialize the UDF
115118 # This would normally fail with ModuleNotFoundError
116119 transformation = PandasTransformation .from_proto (udf_proto , skip_udf = True )
117-
120+
118121 # Should get a dummy transformation with identity function
119122 assert transformation is not None
120123 assert transformation .udf_string == udf_string
121-
124+
122125 # The dummy UDF should be callable and act as identity
123126 test_df = pd .DataFrame ({"col1" : [1 , 2 , 3 ]})
124127 result = transformation .udf (test_df )
@@ -127,32 +130,33 @@ def udf_with_missing_module(df: pd.DataFrame) -> pd.DataFrame:
127130
128131def test_python_transformation_from_proto_with_skip_udf ():
129132 """Test that PythonTransformation.from_proto works with skip_udf=True."""
130-
133+
131134 # Create a UDF that would reference a non-existent module
132135 def udf_with_missing_module (features_dict ):
133136 # This would normally fail if a module is missing during deserialization
134137 import nonexistent_module # noqa: F401
138+
135139 return features_dict
136-
140+
137141 # Serialize the UDF
138142 serialized_udf = dill .dumps (udf_with_missing_module )
139143 udf_string = "import nonexistent_module\n def udf(d): return d"
140-
144+
141145 # Create proto
142146 udf_proto = UserDefinedFunctionProto (
143147 name = "test_udf" ,
144148 body = serialized_udf ,
145149 body_text = udf_string ,
146150 )
147-
151+
148152 # Test that skip_udf=True doesn't try to deserialize the UDF
149153 # This would normally fail with ModuleNotFoundError
150154 transformation = PythonTransformation .from_proto (udf_proto , skip_udf = True )
151-
155+
152156 # Should get a dummy transformation with identity function
153157 assert transformation is not None
154158 assert transformation .udf_string == udf_string
155-
159+
156160 # The dummy UDF should be callable and act as identity
157161 test_dict = {"col1" : 1 }
158162 result = transformation .udf (test_dict )
@@ -212,4 +216,3 @@ def test_skip_validation_use_case_documentation():
212216 - Different teams manage training vs. serving infrastructure
213217 """
214218 pass # This is a documentation test
215-
0 commit comments