88def infer_entity_value_type_from_feature_views (
99 entities : List [Entity ], feature_views : List [FeatureView ]
1010) -> List [Entity ]:
11+ """
12+ Infer entity value type by examining schema of feature view input sources
13+ """
1114 incomplete_entities = {
1215 entity .name : entity
1316 for entity in entities
@@ -17,32 +20,35 @@ def infer_entity_value_type_from_feature_views(
1720
1821 for view in feature_views :
1922 if not (incomplete_entities_keys & set (view .entities )):
20- continue
23+ continue # skip if view doesn't contain any entities that need inference
24+
2125 col_names_and_types = view .input .get_table_column_names_and_types ()
2226 for entity_name in view .entities :
2327 if entity_name in incomplete_entities :
24- entity_col = list (
28+ # get entity information from information extracted from the view input source
29+ extracted_entity_name_type_pairs = list (
2530 filter (lambda tup : tup [0 ] == entity_name , col_names_and_types )
2631 )
27- if len (entity_col ) == 0 :
32+ if len (extracted_entity_name_type_pairs ) == 0 :
2833 # Doesn't mention inference error because would also be an error without inferencing
2934 raise ValueError (
30- f"""No column in the input source for the { view .name } FeatureView matches
31- its Entity 's name."""
35+ f"""No column in the input source for the { view .name } feature view matches
36+ its entity 's name."""
3237 )
3338
3439 entity = incomplete_entities [entity_name ]
3540 inferred_value_type = view .input .source_datatype_to_feast_value_type ()(
36- entity_col [0 ][1 ]
41+ extracted_entity_name_type_pairs [0 ][1 ]
3742 )
43+
3844 if (
3945 entity .value_type != ValueType .UNKNOWN
4046 and entity .value_type != inferred_value_type
41- ) or (len (entity_col ) > 1 ):
47+ ) or (len (extracted_entity_name_type_pairs ) > 1 ):
4248 raise ValueError (
43- f"""Entity value_type inference failed for { entity_name } Entity .
44- Multiple viable matches. Please explicitly specify the Entity value_type
45- for this Entity ."""
49+ f"""Entity value_type inference failed for { entity_name } entity .
50+ Multiple viable matches. Please explicitly specify the entity value_type
51+ for this entity ."""
4652 )
4753
4854 entity .value_type = inferred_value_type
0 commit comments