11from abc import ABC , abstractmethod
22from typing import Union
33
4- from feast import BatchFeatureView , StreamFeatureView
5- from feast .infra .compute_engines .dag .plan import ExecutionPlan
4+ from feast import BatchFeatureView , StreamFeatureView , FeatureView
65from feast .infra .compute_engines .base import HistoricalRetrievalTask
6+ from feast .infra .compute_engines .dag .plan import ExecutionPlan
77from feast .infra .materialization .batch_materialization_engine import MaterializationTask
8+ from feast .infra .compute_engines .dag .node import DAGNode
89
910
1011class DAGBuilder (ABC ):
11- def __init__ (self ,
12- feature_view : Union [BatchFeatureView , StreamFeatureView ],
13- task : Union [MaterializationTask , HistoricalRetrievalTask ]
14- ):
12+ def __init__ (
13+ self ,
14+ feature_view : Union [BatchFeatureView , StreamFeatureView , FeatureView ],
15+ task : Union [MaterializationTask , HistoricalRetrievalTask ],
16+ ):
1517 self .feature_view = feature_view
1618 self .task = task
17- self .nodes = []
19+ self .nodes : list [ DAGNode ] = []
1820
1921 @abstractmethod
2022 def build_source_node (self ):
2123 raise NotImplementedError
2224
2325 @abstractmethod
24- def build_aggregation_node (self ,
25- input_node ):
26+ def build_aggregation_node (self , input_node ):
2627 raise NotImplementedError
2728
2829 @abstractmethod
29- def build_join_node (self ,
30- input_node ):
30+ def build_join_node (self , input_node ):
3131 raise NotImplementedError
3232
3333 @abstractmethod
34- def build_transformation_node (self ,
35- input_node ):
34+ def build_transformation_node (self , input_node ):
3635 raise NotImplementedError
3736
3837 @abstractmethod
39- def build_output_nodes (self ,
40- input_node ):
38+ def build_output_nodes (self , input_node ):
4139 raise NotImplementedError
4240
4341 @abstractmethod
44- def build_validation_node (self ,
45- input_node ):
42+ def build_validation_node (self , input_node ):
4643 raise
4744
4845 def build (self ) -> ExecutionPlan :
4946 last_node = self .build_source_node ()
5047
51- if getattr (self .feature_view . transformation , "requires_aggregation" , False ) :
48+ if hasattr (self .feature_view , "aggregation" ) and self . feature_view . aggregation is not None :
5249 last_node = self .build_aggregation_node (last_node )
5350
5451 if self ._should_join ():
5552 last_node = self .build_join_node (last_node )
5653
57- if self .feature_view . transformation :
54+ if hasattr ( self .feature_view , "feature_transformation" ) and self . feature_view . feature_transformation :
5855 last_node = self .build_transformation_node (last_node )
5956
6057 if getattr (self .feature_view , "enable_validation" , False ):
@@ -65,6 +62,6 @@ def build(self) -> ExecutionPlan:
6562
6663 def _should_join (self ):
6764 return (
68- self .feature_view .compute_config .join_strategy == "engine"
69- or self .task .config .compute_engine .get ("point_in_time_join" ) == "engine"
65+ self .feature_view .compute_config .join_strategy == "engine"
66+ or self .task .config .compute_engine .get ("point_in_time_join" ) == "engine"
7067 )
0 commit comments