1515from enum import Enum
1616from typing import Dict , Union
1717
18- from feast .protos . feast . types . Value_pb2 import ValueType as ValueTypeProto
18+ from feast .value_type import ValueType
1919
2020PRIMITIVE_FEAST_TYPES_TO_VALUE_TYPES = {
21- "INVALID" : "INVALID" ,
22- "STRING" : "STRING" ,
21+ "INVALID" : "UNKNOWN" ,
2322 "BYTES" : "BYTES" ,
24- "BOOL " : "BOOL " ,
23+ "STRING " : "STRING " ,
2524 "INT32" : "INT32" ,
2625 "INT64" : "INT64" ,
27- "FLOAT32" : "FLOAT" ,
2826 "FLOAT64" : "DOUBLE" ,
27+ "FLOAT32" : "FLOAT" ,
28+ "BOOL" : "BOOL" ,
2929 "UNIX_TIMESTAMP" : "UNIX_TIMESTAMP" ,
3030}
3131
@@ -40,14 +40,14 @@ def __init__(self):
4040 pass
4141
4242 @abstractmethod
43- def to_value_type (self ) -> ValueTypeProto . Enum :
43+ def to_value_type (self ) -> ValueType :
4444 """
45- Converts a ComplexFeastType object to the corresponding ValueTypeProto.Enum value .
45+ Converts a ComplexFeastType object to the corresponding ValueType enum .
4646 """
4747 raise NotImplementedError
4848
4949 def __hash__ (self ):
50- return hash (self .to_value_type ())
50+ return hash (self .to_value_type (). value )
5151
5252 def __eq__ (self , other ):
5353 return self .to_value_type () == other .to_value_type ()
@@ -57,8 +57,7 @@ class PrimitiveFeastType(Enum):
5757 """
5858 A PrimitiveFeastType represents a primitive type in Feast.
5959
60- Note that these values must match the values in ValueTypeProto.Enum. See
61- /feast/protos/types/Value.proto for the exact values.
60+ Note that these values must match the values in /feast/protos/types/Value.proto.
6261 """
6362
6463 INVALID = 0
@@ -71,12 +70,12 @@ class PrimitiveFeastType(Enum):
7170 BOOL = 7
7271 UNIX_TIMESTAMP = 8
7372
74- def to_value_type (self ) -> ValueTypeProto . Enum :
73+ def to_value_type (self ) -> ValueType :
7574 """
76- Converts a PrimitiveFeastType object to the corresponding ValueTypeProto.Enum value .
75+ Converts a PrimitiveFeastType object to the corresponding ValueType enum .
7776 """
7877 value_type_name = PRIMITIVE_FEAST_TYPES_TO_VALUE_TYPES [self .name ]
79- return ValueTypeProto . Enum . Value ( value_type_name )
78+ return ValueType [ value_type_name ]
8079
8180 def __str__ (self ):
8281 return PRIMITIVE_FEAST_TYPES_TO_STRING [self .name ]
@@ -136,11 +135,11 @@ def __init__(self, base_type: Union[PrimitiveFeastType, ComplexFeastType]):
136135
137136 self .base_type = base_type
138137
139- def to_value_type (self ) -> int :
138+ def to_value_type (self ) -> ValueType :
140139 assert isinstance (self .base_type , PrimitiveFeastType )
141140 value_type_name = PRIMITIVE_FEAST_TYPES_TO_VALUE_TYPES [self .base_type .name ]
142141 value_type_list_name = value_type_name + "_LIST"
143- return ValueTypeProto . Enum . Value ( value_type_list_name )
142+ return ValueType [ value_type_list_name ]
144143
145144 def __str__ (self ):
146145 return f"Array({ self .base_type } )"
@@ -149,33 +148,33 @@ def __str__(self):
149148FeastType = Union [ComplexFeastType , PrimitiveFeastType ]
150149
151150
152- VALUE_TYPES_TO_FEAST_TYPES : Dict ["ValueTypeProto.Enum " , FeastType ] = {
153- ValueTypeProto . Enum . INVALID : Invalid ,
154- ValueTypeProto . Enum .BYTES : Bytes ,
155- ValueTypeProto . Enum .STRING : String ,
156- ValueTypeProto . Enum .INT32 : Int32 ,
157- ValueTypeProto . Enum .INT64 : Int64 ,
158- ValueTypeProto . Enum .DOUBLE : Float64 ,
159- ValueTypeProto . Enum .FLOAT : Float32 ,
160- ValueTypeProto . Enum .BOOL : Bool ,
161- ValueTypeProto . Enum .UNIX_TIMESTAMP : UnixTimestamp ,
162- ValueTypeProto . Enum .BYTES_LIST : Array (Bytes ),
163- ValueTypeProto . Enum .STRING_LIST : Array (String ),
164- ValueTypeProto . Enum .INT32_LIST : Array (Int32 ),
165- ValueTypeProto . Enum .INT64_LIST : Array (Int64 ),
166- ValueTypeProto . Enum .DOUBLE_LIST : Array (Float64 ),
167- ValueTypeProto . Enum .FLOAT_LIST : Array (Float32 ),
168- ValueTypeProto . Enum .BOOL_LIST : Array (Bool ),
169- ValueTypeProto . Enum .UNIX_TIMESTAMP_LIST : Array (UnixTimestamp ),
151+ VALUE_TYPES_TO_FEAST_TYPES : Dict ["ValueType " , FeastType ] = {
152+ ValueType . UNKNOWN : Invalid ,
153+ ValueType .BYTES : Bytes ,
154+ ValueType .STRING : String ,
155+ ValueType .INT32 : Int32 ,
156+ ValueType .INT64 : Int64 ,
157+ ValueType .DOUBLE : Float64 ,
158+ ValueType .FLOAT : Float32 ,
159+ ValueType .BOOL : Bool ,
160+ ValueType .UNIX_TIMESTAMP : UnixTimestamp ,
161+ ValueType .BYTES_LIST : Array (Bytes ),
162+ ValueType .STRING_LIST : Array (String ),
163+ ValueType .INT32_LIST : Array (Int32 ),
164+ ValueType .INT64_LIST : Array (Int64 ),
165+ ValueType .DOUBLE_LIST : Array (Float64 ),
166+ ValueType .FLOAT_LIST : Array (Float32 ),
167+ ValueType .BOOL_LIST : Array (Bool ),
168+ ValueType .UNIX_TIMESTAMP_LIST : Array (UnixTimestamp ),
170169}
171170
172171
173- def from_value_type (value_type : ValueTypeProto . Enum ,) -> FeastType :
172+ def from_value_type (value_type : ValueType ,) -> FeastType :
174173 """
175- Converts a ValueTypeProto.Enum to a Feast type.
174+ Converts a ValueType enum to a Feast type.
176175
177176 Args:
178- value_type: The ValueTypeProto.Enum to be converted.
177+ value_type: The ValueType to be converted.
179178
180179 Raises:
181180 ValueError: The conversion could not be performed.
0 commit comments