11"""
22Unit tests for dual registration functionality in FeatureStore.
33
4- Tests that online_enabled =True FeatureViews get automatically registered
4+ Tests that online =True FeatureViews get automatically registered
55as both batch FeatureViews and OnDemandFeatureViews for serving.
66"""
77
2020class TestDualRegistration :
2121 """Test dual registration functionality"""
2222
23- def test_online_enabled_creates_odfv (self ):
24- """Test that online_enabled =True creates an OnDemandFeatureView"""
25- # Create a FeatureView with online_enabled =True
23+ def test_online_creates_odfv (self ):
24+ """Test that online =True creates an OnDemandFeatureView"""
25+ # Create a FeatureView with online =True
2626 driver = Entity (name = "driver" , join_keys = ["driver_id" ])
2727 mock_source = FileSource (path = "test.parquet" , timestamp_field = "ts" )
2828
@@ -37,8 +37,8 @@ def test_online_enabled_creates_odfv(self):
3737 entities = [driver ],
3838 schema = [Field (name = "feature1" , dtype = Float64 )],
3939 feature_transformation = test_transformation ,
40- when = "on_write " ,
41- online_enabled = True ,
40+ transform_when = "batch_on_write " ,
41+ # online =True auto-inferred from transform_when
4242 )
4343
4444 # Mock registry and provider
@@ -96,7 +96,7 @@ def capture_feature_view(view, project, commit):
9696 # Verify original FV
9797 assert original_fv is not None
9898 assert original_fv .name == "test_fv"
99- assert original_fv .online_enabled
99+ assert original_fv .online
100100 assert original_fv .feature_transformation is not None
101101
102102 # Verify generated ODFV
@@ -109,7 +109,7 @@ def capture_feature_view(view, project, commit):
109109 assert generated_odfv .tags ["dual_registration" ] == "true"
110110
111111 def test_no_dual_registration_when_online_disabled (self ):
112- """Test that online_enabled =False does not create ODFV"""
112+ """Test that online =False does not create ODFV"""
113113 driver = Entity (name = "driver" , join_keys = ["driver_id" ])
114114 mock_source = FileSource (path = "test.parquet" , timestamp_field = "ts" )
115115
@@ -118,7 +118,7 @@ def test_no_dual_registration_when_online_disabled(self):
118118 source = mock_source ,
119119 entities = [driver ],
120120 schema = [Field (name = "feature1" , dtype = Float64 )],
121- online_enabled = False , # Disabled
121+ online = False , # Disabled
122122 )
123123
124124 # Mock FeatureStore
@@ -163,7 +163,7 @@ def test_no_dual_registration_without_transformation(self):
163163 source = mock_source ,
164164 entities = [driver ],
165165 schema = [Field (name = "feature1" , dtype = Float64 )],
166- online_enabled = True , # Enabled
166+ online = True , # Enabled
167167 # No feature_transformation
168168 )
169169
@@ -199,31 +199,35 @@ def test_no_dual_registration_without_transformation(self):
199199 assert isinstance (applied_views [0 ], FeatureView )
200200 assert not isinstance (applied_views [0 ], OnDemandFeatureView )
201201
202- def test_enhanced_decorator_with_dual_registration (self ):
203- """Test end-to-end: enhanced @ transformation decorator -> dual registration"""
202+ def test_separate_transformation_and_feature_view_with_dual_registration (self ):
203+ """Test: create separate transformation and FeatureView -> dual registration"""
204204 driver = Entity (name = "driver" , join_keys = ["driver_id" ])
205205
206- # Create FeatureView using enhanced decorator with dummy source
206+ # Create transformation separately
207+ @transformation (mode = "python" , name = "doubling_transform" )
208+ def doubling_transform_func (inputs ):
209+ return [{"doubled" : inp .get ("value" , 0 ) * 2 } for inp in inputs ]
210+
211+ # Create FeatureView with transformation and dual registration settings
207212 dummy_source = FileSource (
208213 path = "test.parquet" , timestamp_field = "event_timestamp"
209214 )
210215
211- @transformation (
212- mode = "python" ,
213- when = "on_write" ,
214- online = True ,
215- sources = [dummy_source ],
216- schema = [Field (name = "doubled" , dtype = Float64 )],
217- entities = [driver ],
216+ fv = FeatureView (
218217 name = "doubling_transform" ,
218+ source = dummy_source ,
219+ entities = [driver ],
220+ schema = [Field (name = "doubled" , dtype = Float64 )],
221+ feature_transformation = doubling_transform_func ,
222+ transform_when = "batch_on_write" ,
223+ # online=True auto-inferred from transform_when
219224 )
220- def doubling_transform (inputs ):
221- return [{"doubled" : inp .get ("value" , 0 ) * 2 } for inp in inputs ]
222225
223226 # Verify it's a FeatureView with the right properties
224- assert isinstance (doubling_transform , FeatureView )
225- assert doubling_transform .online_enabled
226- assert doubling_transform .feature_transformation is not None
227+ assert isinstance (fv , FeatureView )
228+ assert fv .online # Auto-inferred
229+ assert fv .transform_when == "batch_on_write"
230+ assert fv .feature_transformation is not None
227231
228232 # Mock FeatureStore and apply
229233 # Create FeatureStore instance with mocked initialization
@@ -250,7 +254,7 @@ def doubling_transform(inputs):
250254 fs ._provider .teardown_infra = Mock ()
251255
252256 # Apply the FeatureView
253- fs .apply (doubling_transform )
257+ fs .apply (fv )
254258
255259 # Should create both original FV and ODFV
256260 assert len (applied_views ) == 2
@@ -266,7 +270,7 @@ def doubling_transform(inputs):
266270 test_input = [{"value" : 5 }]
267271 expected_output = [{"doubled" : 10 }]
268272
269- original_udf = doubling_transform .feature_transformation .udf
273+ original_udf = fv .feature_transformation .udf
270274 odfv_udf = odfv .feature_transformation .udf
271275
272276 assert original_udf (test_input ) == expected_output
0 commit comments