@@ -46,7 +46,9 @@ def id(self):
4646OptionId : Type [SchemaId ] = SchemaId # enum option
4747Number : Type [float ] = float
4848
49- DataRowMetadataValue = Union [Embedding , DateTime , String , OptionId , Number ]
49+ DataRowMetadataValue = Union [Embedding , Number , DateTime , String , OptionId ]
50+ # primitives used in uploads
51+ _DataRowMetadataValuePrimitives = Union [str , List , dict , float ]
5052
5153
5254class _CamelCaseMixin (BaseModel ):
@@ -84,7 +86,7 @@ class DataRowMetadataBatchResponse(_CamelCaseMixin):
8486# Bulk upsert values
8587class _UpsertDataRowMetadataInput (_CamelCaseMixin ):
8688 schema_id : str
87- value : Union [ str , List , dict ]
89+ value : _DataRowMetadataValuePrimitives
8890
8991
9092# Batch of upsert values for a datarow
@@ -121,27 +123,24 @@ def __init__(self, client):
121123
122124 self ._raw_ontology = self ._get_ontology ()
123125
126+ def _build_ontology (self ):
124127 # all fields
125- self .fields = self ._parse_ontology ()
128+ self .fields = self ._parse_ontology (self . _raw_ontology )
126129 self .fields_by_id = self ._make_id_index (self .fields )
127130
128131 # reserved fields
129132 self .reserved_fields : List [DataRowMetadataSchema ] = [
130133 f for f in self .fields if f .reserved
131134 ]
132135 self .reserved_by_id = self ._make_id_index (self .reserved_fields )
133- self .reserved_by_name : Dict [str , DataRowMetadataSchema ] = {
134- f .name : f for f in self .reserved_fields
135- }
136+ self .reserved_by_name : Dict [str , DataRowMetadataSchema ] = self ._make_name_index (self .reserved_fields )
136137
137138 # custom fields
138139 self .custom_fields : List [DataRowMetadataSchema ] = [
139140 f for f in self .fields if not f .reserved
140141 ]
141142 self .custom_by_id = self ._make_id_index (self .custom_fields )
142- self .custom_by_name : Dict [str , DataRowMetadataSchema ] = {
143- f .name : f for f in self .custom_fields
144- }
143+ self .custom_by_name : Dict [str , DataRowMetadataSchema ] = self ._make_name_index (self .custom_fields )
145144
146145 @staticmethod
147146 def _make_name_index (fields : List [DataRowMetadataSchema ]):
@@ -184,9 +183,10 @@ def _get_ontology(self) -> List[Dict[str, Any]]:
184183 """
185184 return self ._client .execute (query )["customMetadataOntology" ]
186185
187- def _parse_ontology (self ) -> List [DataRowMetadataSchema ]:
186+ @staticmethod
187+ def _parse_ontology (raw_ontology ) -> List [DataRowMetadataSchema ]:
188188 fields = []
189- for schema in self . _raw_ontology :
189+ for schema in raw_ontology :
190190 schema ["uid" ] = schema .pop ("id" )
191191 options = None
192192 if schema .get ("options" ):
0 commit comments