Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def to_proto(self) -> EntityProto:
"""
Converts Entity to its Protocol Buffer representation
Returns:
Returns EntitySpec object
"""
value_type = ValueTypeProto.ValueType.Enum.Value(self.dtype.name)
return EntityProto(name=self.name, value_type=value_type)
def to_proto(self) -> FeatureProto:
"""Converts Feature object to its Protocol Buffer representation"""
value_type = ValueTypeProto.ValueType.Enum.Value(self.dtype.name)
return FeatureProto(name=self.name, value_type=value_type)
"""
# Mapping of PyArrow to attribute name in Feast ValueType
type_map = {
"timestamp[ms]": ProtoValueType.INT64,
"int32": ProtoValueType.INT32,
"int64": ProtoValueType.INT64,
"double": ProtoValueType.DOUBLE,
"float": ProtoValueType.FLOAT,
"string": ProtoValueType.STRING,
"binary": ProtoValueType.BYTES,
"bool": ProtoValueType.BOOL,
"list": ProtoValueType.INT32_LIST,
"list": ProtoValueType.INT64_LIST,
"list": ProtoValueType.DOUBLE_LIST,
"list": ProtoValueType.FLOAT_LIST,
"list": ProtoValueType.STRING_LIST,
"list": ProtoValueType.BYTES_LIST,
"list": ProtoValueType.BOOL_LIST,
}
return type_map[pa_type.__str__()]
"""
Returns the equivalent Feast ValueType for the given pa.lib type.
Args:
pa_type (object):
PyArrow type.
Returns:
feast.types.Value_pb2.ValueType:
Feast ValueType.
"""
# Mapping of PyArrow to attribute name in Feast ValueType
type_map = {
"timestamp[ms]": ProtoValueType.INT64,
"int32": ProtoValueType.INT32,
"int64": ProtoValueType.INT64,
"double": ProtoValueType.DOUBLE,
"float": ProtoValueType.FLOAT,
"string": ProtoValueType.STRING,
"binary": ProtoValueType.BYTES,
"bool": ProtoValueType.BOOL,
"list": ProtoValueType.INT32_LIST,
"list": ProtoValueType.INT64_LIST,
"list": ProtoValueType.DOUBLE_LIST,
"list": ProtoValueType.FLOAT_LIST,
"list": ProtoValueType.STRING_LIST,
"list": ProtoValueType.BYTES_LIST,
"list": ProtoValueType.BOOL_LIST,
}
return type_map[pa_type.__str__()]
def dtype_to_value_type(dtype):
"""Returns the equivalent feast valueType for the given dtype
Args:
dtype (pandas.dtype): pandas dtype
Returns:
feast.types.ValueType2.ValueType: equivalent feast valuetype
"""
# mapping of pandas dtypes to feast value type strings
type_map = {
"float64": ValueType.DOUBLE,
"float32": ValueType.FLOAT,
"int64": ValueType.INT64,
"uint64": ValueType.INT64,
"int32": ValueType.INT32,
"uint32": ValueType.INT32,
"uint8": ValueType.INT32,
"int8": ValueType.INT32,
"bool": ValueType.BOOL,
"timedelta": ValueType.INT64,
"datetime64[ns]": ValueType.TIMESTAMP,
"datetime64[ns, UTC]": ValueType.TIMESTAMP,
"category": ValueType.STRING,
"object": ValueType.STRING,
}
return type_map[dtype.__str__()]
def dtype_to_value_type(dtype):
"""Returns the equivalent feast valueType for the given dtype
Args:
dtype (pandas.dtype): pandas dtype
Returns:
feast.types.ValueType2.ValueType: equivalent feast valuetype
"""
# mapping of pandas dtypes to feast value type strings
type_map = {
"float64": ValueType.DOUBLE,
"float32": ValueType.FLOAT,
"int64": ValueType.INT64,
"uint64": ValueType.INT64,
"int32": ValueType.INT32,
"uint32": ValueType.INT32,
"uint8": ValueType.INT32,
"int8": ValueType.INT32,
"bool": ValueType.BOOL,
"timedelta": ValueType.INT64,
"datetime64[ns]": ValueType.TIMESTAMP,
"datetime64[ns, UTC]": ValueType.TIMESTAMP,
"category": ValueType.STRING,
"object": ValueType.STRING,
}
return type_map[dtype.__str__()]