4444from lib .core .entities import AttachmentEntity
4545from lib .core .entities import SettingEntity
4646from lib .core .entities .classes import AnnotationClassEntity
47+ from lib .core .entities .classes import AttributeGroup
4748from lib .core .entities .integrations import IntegrationEntity
4849from lib .core .enums import ImageQuality
4950from lib .core .exceptions import AppException
50- from lib .core .types import AttributeGroup
5151from lib .core .types import MLModel
5252from lib .core .types import PriorityScore
5353from lib .core .types import Project
54- from lib .infrastructure .controller import Controller
5554from lib .infrastructure .validators import wrap_error
5655from pydantic import conlist
5756from pydantic import parse_obj_as
@@ -1141,19 +1140,76 @@ def create_annotation_class(
11411140
11421141 :param project: project name
11431142 :type project: str
1143+
11441144 :param name: name for the class
11451145 :type name: str
1146- :param color: RGB hex color value, e.g., "#FFFFAA"
1146+
1147+ :param color: RGB hex color value, e.g., "#F9E0FA"
11471148 :type color: str
1148- :param attribute_groups: example:
1149- [ { "name": "tall", "is_multiselect": 0, "attributes": [ { "name": "yes" }, { "name": "no" } ] },
1150- { "name": "age", "is_multiselect": 0, "attributes": [ { "name": "young" }, { "name": "old" } ] } ]
1149+
1150+ :param attribute_groups: list of attribute group dicts.
1151+ The values for the "group_type" key are "radio"|"checklist"|"text"|"numeric".
1152+ Mandatory keys for each attribute group are
1153+ - "name"
11511154 :type attribute_groups: list of dicts
1152- :param class_type: class type
1155+
1156+ :param class_type: class type. Should be either "object" or "tag"
11531157 :type class_type: str
11541158
11551159 :return: new class metadata
11561160 :rtype: dict
1161+
1162+ Request Example:
1163+ ::
1164+ attributes_list = [
1165+ {
1166+ "group_type": "radio",
1167+ "name": "Vehicle",
1168+ "attributes": [
1169+ {
1170+ "name": "Car"
1171+ },
1172+ {
1173+ "name": "Track"
1174+ },
1175+ {
1176+ "name": "Bus"
1177+ }
1178+ ],
1179+ "default_value": "Car"
1180+ },
1181+ {
1182+ "group_type": "checklist",
1183+ "name": "Color",
1184+ "attributes": [
1185+ {
1186+ "name": "Yellow"
1187+ },
1188+ {
1189+ "name": "Black"
1190+ },
1191+ {
1192+ "name": "White"
1193+ }
1194+ ],
1195+ "default_value": ["Yellow", "White"]
1196+ },
1197+ {
1198+ "group_type": "text",
1199+ "name": "Timestamp"
1200+ },
1201+ {
1202+ "group_type": "numeric",
1203+ "name": "Description"
1204+ }
1205+ ]
1206+ client.create_annotation_class(
1207+ project="Image Project",
1208+ name="Example Class",
1209+ color="#F9E0FA",
1210+ attribute_groups=attributes_list
1211+ )
1212+
11571213 """
11581214 if isinstance (project , Project ):
11591215 project = project .dict ()
@@ -1837,7 +1893,6 @@ def add_annotation_point_to_image(
18371893 annotations ,
18381894 point ,
18391895 annotation_class_name ,
1840- image_name ,
18411896 annotation_class_attributes ,
18421897 error ,
18431898 )
@@ -2112,7 +2167,9 @@ def delete_annotations(
21122167 raise AppException (response .errors )
21132168
21142169 def validate_annotations (
2115- self , project_type : ProjectTypes , annotations_json : Union [NotEmptyStr , Path , dict ]
2170+ self ,
2171+ project_type : ProjectTypes ,
2172+ annotations_json : Union [NotEmptyStr , Path , dict ],
21162173 ):
21172174 """Validates given annotation JSON.
21182175
@@ -2129,9 +2186,7 @@ def validate_annotations(
21292186 annotation_data = annotations_json
21302187 else :
21312188 annotation_data = json .load (open (annotations_json ))
2132- response = self .controller .validate_annotations (
2133- project_type , annotation_data
2134- )
2189+ response = self .controller .validate_annotations (project_type , annotation_data )
21352190 if response .errors :
21362191 raise AppException (response .errors )
21372192 report = response .data
0 commit comments