88from typing import Dict
99from typing import List
1010
11- import lib .core as constances
12- from lib .core .enums import ClassTypeEnum
13- from lib .core .reporter import Reporter
1411from superannotate_schemas .schemas .classes import AnnotationClass
1512from superannotate_schemas .schemas .classes import Attribute
1613from superannotate_schemas .schemas .classes import AttributeGroup
1714
15+ import lib .core as constances
16+ from lib .core .enums import ClassTypeEnum
17+ from lib .core .reporter import Reporter
18+
1819
1920class BaseDataHandler (metaclass = ABCMeta ):
2021 @abstractmethod
@@ -40,17 +41,15 @@ def __init__(self, annotation_classes: List[AnnotationClass]):
4041
4142 @lru_cache ()
4243 def get_annotation_class (
43- self , name : str , class_type : ClassTypeEnum
44+ self , name : str
4445 ) -> AnnotationClass :
4546 for annotation_class in self ._annotation_classes :
46- if annotation_class .name == name and class_type .equals (
47- annotation_class .type
48- ):
47+ if annotation_class .name == name :
4948 return annotation_class
5049
5150 @lru_cache ()
5251 def get_attribute_group (
53- self , annotation_class : AnnotationClass , attr_group_name : str
52+ self , annotation_class : AnnotationClass , attr_group_name : str
5453 ) -> AttributeGroup :
5554 for attr_group in annotation_class .attribute_groups :
5655 if attr_group .name == attr_group_name :
@@ -108,9 +107,7 @@ class DocumentTagHandler(BaseAnnotationDateHandler):
108107 def handle (self , annotation : dict ):
109108 new_tags = []
110109 for tag in annotation ["tags" ]:
111- annotation_class = self .get_annotation_class (
112- tag , class_type = ClassTypeEnum .OBJECT
113- )
110+ annotation_class = self .get_annotation_class (tag )
114111 if annotation_class :
115112 new_tags .append (annotation_class .id )
116113 annotation ["tags" ] = new_tags
@@ -119,10 +116,10 @@ def handle(self, annotation: dict):
119116
120117class MissingIDsHandler (BaseAnnotationDateHandler ):
121118 def __init__ (
122- self ,
123- annotation_classes : List [AnnotationClass ],
124- templates : List [dict ],
125- reporter : Reporter ,
119+ self ,
120+ annotation_classes : List [AnnotationClass ],
121+ templates : List [dict ],
122+ reporter : Reporter ,
126123 ):
127124 super ().__init__ (annotation_classes )
128125 self .validate_existing_classes (annotation_classes )
@@ -175,9 +172,7 @@ def handle(self, annotation: dict):
175172 annotation_instance ["classId" ] = - 1
176173 else :
177174 class_name = annotation_instance ["className" ]
178- annotation_type = annotation_instance .get ("type" , ClassTypeEnum .OBJECT )
179- class_type = self ._get_class_type (annotation_type )
180- annotation_class = self .get_annotation_class (class_name , class_type )
175+ annotation_class = self .get_annotation_class (class_name )
181176 if not annotation_class :
182177 self .reporter .log_warning (f"Couldn't find class { class_name } " )
183178 self .reporter .store_message ("missing_classes" , class_name )
@@ -199,7 +194,7 @@ def handle(self, annotation: dict):
199194 template ["name" ]: template ["id" ] for template in self ._templates
200195 }
201196 for annotation_instance in (
202- i for i in annotation ["instances" ] if i .get ("type" , None ) == "template"
197+ i for i in annotation ["instances" ] if i .get ("type" , None ) == "template"
203198 ):
204199 annotation_instance ["templateId" ] = template_name_id_map .get (
205200 annotation_instance .get ("templateName" , "" ), - 1
@@ -209,13 +204,8 @@ def handle(self, annotation: dict):
209204 i for i in annotation ["instances" ] if "className" in i and i ["classId" ] > 0
210205 ]:
211206 annotation_class_name = annotation_instance ["className" ]
212- annotation_class_type = self ._get_class_type (
213- annotation_instance .get ("type" , ClassTypeEnum .OBJECT )
214- )
207+ annotation_class = self .get_annotation_class (annotation_class_name )
215208
216- annotation_class = self .get_annotation_class (
217- annotation_class_name , annotation_class_type
218- )
219209 if not annotation_class :
220210 self .reporter .log_warning (
221211 f"Couldn't find annotation class { annotation_class_name } "
@@ -291,9 +281,7 @@ def convert_timestamp(timestamp):
291281 "locked" : False ,
292282 }
293283 if class_name :
294- annotation_class = self .get_annotation_class (
295- class_name , ClassTypeEnum .OBJECT
296- )
284+ annotation_class = self .get_annotation_class (class_name )
297285 if annotation_class :
298286 editor_instance ["classId" ] = annotation_class .id
299287 else :
@@ -328,9 +316,7 @@ def convert_timestamp(timestamp):
328316 ] = timestamp_data ["points" ]
329317 if not class_name :
330318 continue
331- annotation_class = self .get_annotation_class (
332- class_name , ClassTypeEnum .OBJECT
333- )
319+ annotation_class = self .get_annotation_class (class_name )
334320 if not annotation_class :
335321 self .reporter .store_message (
336322 "missing_classes" , meta ["className" ]
@@ -365,10 +351,10 @@ def convert_timestamp(timestamp):
365351 (group_name , attr_name )
366352 )
367353 attributes_to_add = (
368- existing_attributes_in_current_instance - active_attributes
354+ existing_attributes_in_current_instance - active_attributes
369355 )
370356 attributes_to_delete = (
371- active_attributes - existing_attributes_in_current_instance
357+ active_attributes - existing_attributes_in_current_instance
372358 )
373359 if attributes_to_add or attributes_to_delete :
374360 editor_instance ["timeline" ][timestamp ][
0 commit comments