MCPcopy Index your code
hub / github.com/feast-dev/feast / from_proto

Method from_proto

sdk/python/feast/field.py:148–191  ·  view source on GitHub ↗

Creates a Field object from a protobuf representation. Args: field_proto: FieldProto protobuf object

(cls, field_proto: FieldProto)

Source from the content-addressed store, hash-verified

146
147 @classmethod
148 def from_proto(cls, field_proto: FieldProto):
149 """
150 Creates a Field object from a protobuf representation.
151
152 Args:
153 field_proto: FieldProto protobuf object
154 """
155 value_type = ValueType(field_proto.value_type)
156 tags = dict(field_proto.tags)
157 vector_search_metric = getattr(field_proto, "vector_search_metric", "")
158 vector_index = getattr(field_proto, "vector_index", False)
159 vector_length = getattr(field_proto, "vector_length", 0)
160
161 # Reconstruct Struct type from persisted schema in tags
162 from feast.types import Array
163
164 internal_tags = {STRUCT_SCHEMA_TAG, NESTED_COLLECTION_INNER_TYPE_TAG}
165 dtype: FeastType
166 if value_type == ValueType.STRUCT and STRUCT_SCHEMA_TAG in tags:
167 dtype = _deserialize_struct_schema(tags[STRUCT_SCHEMA_TAG])
168 user_tags = {k: v for k, v in tags.items() if k not in internal_tags}
169 elif value_type == ValueType.STRUCT_LIST and STRUCT_SCHEMA_TAG in tags:
170 inner_struct = _deserialize_struct_schema(tags[STRUCT_SCHEMA_TAG])
171 dtype = Array(inner_struct)
172 user_tags = {k: v for k, v in tags.items() if k not in internal_tags}
173 elif (
174 value_type in (ValueType.VALUE_LIST, ValueType.VALUE_SET)
175 and NESTED_COLLECTION_INNER_TYPE_TAG in tags
176 ):
177 dtype = _str_to_feast_type(tags[NESTED_COLLECTION_INNER_TYPE_TAG])
178 user_tags = {k: v for k, v in tags.items() if k not in internal_tags}
179 else:
180 dtype = from_value_type(value_type=value_type)
181 user_tags = {k: v for k, v in tags.items() if k not in internal_tags}
182
183 return cls(
184 name=field_proto.name,
185 dtype=dtype,
186 tags=user_tags,
187 description=field_proto.description,
188 vector_index=vector_index,
189 vector_length=vector_length,
190 vector_search_metric=vector_search_metric,
191 )
192
193 @classmethod
194 def from_feature(cls, feature: Feature):

Callers 15

ApplyEntityMethod · 0.45
ApplyDataSourceMethod · 0.45
ApplyFeatureViewMethod · 0.45
ApplyFeatureServiceMethod · 0.45
ApplySavedDatasetMethod · 0.45
ApplyMaterializationMethod · 0.45
UpdateInfraMethod · 0.45
ApplyPermissionMethod · 0.45
ApplyProjectMethod · 0.45

Calls 5

ValueTypeClass · 0.90
ArrayClass · 0.90
from_value_typeFunction · 0.90
_str_to_feast_typeFunction · 0.85