File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ import uuid
2+ from labelbox .data .annotation_types .annotation import ObjectAnnotation
3+
4+ from labelbox .schema .annotation_import import LabelImport
5+
6+
7+ def test_export_annotations_nested_checklist (
8+ client , configured_project_with_complex_ontology ):
9+ project , data_row = configured_project_with_complex_ontology
10+ ontology = project .ontology ().normalized
11+
12+ tool = ontology ["tools" ][0 ]
13+
14+ nested_check = [
15+ subc for subc in tool ["classifications" ]
16+ if subc ["name" ] == "test-checklist-class"
17+ ][0 ]
18+
19+ data = [{
20+ "uuid" :
21+ str (uuid .uuid4 ()),
22+ "schemaId" :
23+ tool ['featureSchemaId' ],
24+ "dataRow" : {
25+ "id" : data_row .uid
26+ },
27+ "bbox" : {
28+ "top" : 20 ,
29+ "left" : 20 ,
30+ "height" : 50 ,
31+ "width" : 50
32+ },
33+ "classifications" : [{
34+ "schemaId" :
35+ nested_check ["featureSchemaId" ],
36+ "answers" : [
37+ {
38+ "schemaId" : nested_check ["options" ][0 ]["featureSchemaId" ]
39+ },
40+ {
41+ "schemaId" : nested_check ["options" ][1 ]["featureSchemaId" ]
42+ },
43+ ]
44+ }]
45+ }]
46+
47+ task = LabelImport .create_from_objects (client , project .uid ,
48+ f'label-import-{ uuid .uuid4 ()} ' ,
49+ data )
50+ task .wait_until_done ()
51+ labels = project .label_generator ().as_list ()
52+ object_annotation = [
53+ annot for annot in next (labels ).annotations
54+ if isinstance (annot , ObjectAnnotation )
55+ ][0 ]
56+
57+ nested_class_answers = object_annotation .classifications [0 ].value .answer
58+ assert len (nested_class_answers ) == 2
You can’t perform that action at this time.
0 commit comments