@@ -656,7 +656,7 @@ def configured_project_with_label(
656656 [data_row .uid ], # sample of data row objects
657657 5 , # priority between 1(Highest) - 5(lowest)
658658 )
659- ontology = _setup_ontology (project )
659+ ontology = _setup_ontology (project , client )
660660 label = _create_label (
661661 project , data_row , ontology , wait_for_label_processing
662662 )
@@ -699,20 +699,19 @@ def create_label():
699699 return label
700700
701701
702- def _setup_ontology (project ):
703- editor = list (
704- project .client .get_labeling_frontends (
705- where = LabelingFrontend .name == "editor"
706- )
707- )[0 ]
702+ def _setup_ontology (project : Project , client : Client ):
708703 ontology_builder = OntologyBuilder (
709704 tools = [
710705 Tool (tool = Tool .Type .BBOX , name = "test-bbox-class" ),
711706 ]
712707 )
713- project .setup (editor , ontology_builder .asdict ())
714- # TODO: ontology may not be synchronous after setup. remove sleep when api is more consistent
715- time .sleep (2 )
708+ ontology = client .create_ontology (
709+ name = "ontology with features" ,
710+ media_type = MediaType .Image ,
711+ normalized = ontology_builder .asdict (),
712+ )
713+ project .connect_ontology (ontology )
714+
716715 return OntologyBuilder .from_project (project )
717716
718717
@@ -754,7 +753,7 @@ def configured_batch_project_with_label(
754753 project .create_batch ("test-batch" , data_rows )
755754 project .data_row_ids = data_rows
756755
757- ontology = _setup_ontology (project )
756+ ontology = _setup_ontology (project , client )
758757 label = _create_label (
759758 project , data_row , ontology , wait_for_label_processing
760759 )
@@ -786,7 +785,7 @@ def configured_batch_project_with_multiple_datarows(
786785 batch_name = f"batch { uuid .uuid4 ()} "
787786 project .create_batch (batch_name , global_keys = global_keys )
788787
789- ontology = _setup_ontology (project )
788+ ontology = _setup_ontology (project , client )
790789 for datarow in data_rows :
791790 _create_label (project , datarow , ontology , wait_for_label_processing )
792791
@@ -1023,11 +1022,11 @@ def _upload_invalid_data_rows_for_dataset(dataset: Dataset):
10231022
10241023@pytest .fixture
10251024def configured_project (
1026- project_with_empty_ontology , initial_dataset , rand_gen , image_url
1025+ project_with_one_feature_ontology , initial_dataset , rand_gen , image_url
10271026):
10281027 dataset = initial_dataset
10291028 data_row_id = dataset .create_data_row (row_data = image_url ).uid
1030- project = project_with_empty_ontology
1029+ project = project_with_one_feature_ontology
10311030
10321031 batch = project .create_batch (
10331032 rand_gen (str ),
@@ -1042,20 +1041,21 @@ def configured_project(
10421041
10431042
10441043@pytest .fixture
1045- def project_with_empty_ontology (project ):
1046- editor = list (
1047- project .client .get_labeling_frontends (
1048- where = LabelingFrontend .name == "editor"
1049- )
1050- )[0 ]
1051- empty_ontology = {"tools" : [], "classifications" : []}
1052- project .setup (editor , empty_ontology )
1044+ def project_with_one_feature_ontology (project , client : Client ):
1045+ tools = [
1046+ Tool (tool = Tool .Type .BBOX , name = "test-bbox-class" ).asdict (),
1047+ ]
1048+ empty_ontology = {"tools" : tools , "classifications" : []}
1049+ ontology = client .create_ontology (
1050+ "empty ontology" , empty_ontology , MediaType .Image
1051+ )
1052+ project .connect_ontology (ontology )
10531053 yield project
10541054
10551055
10561056@pytest .fixture
10571057def configured_project_with_complex_ontology (
1058- client , initial_dataset , rand_gen , image_url , teardown_helpers
1058+ client : Client , initial_dataset , rand_gen , image_url , teardown_helpers
10591059):
10601060 project = client .create_project (
10611061 name = rand_gen (str ),
@@ -1072,19 +1072,12 @@ def configured_project_with_complex_ontology(
10721072 )
10731073 project .data_row_ids = data_row_ids
10741074
1075- editor = list (
1076- project .client .get_labeling_frontends (
1077- where = LabelingFrontend .name == "editor"
1078- )
1079- )[0 ]
1080-
10811075 ontology = OntologyBuilder ()
10821076 tools = [
10831077 Tool (tool = Tool .Type .BBOX , name = "test-bbox-class" ),
10841078 Tool (tool = Tool .Type .LINE , name = "test-line-class" ),
10851079 Tool (tool = Tool .Type .POINT , name = "test-point-class" ),
10861080 Tool (tool = Tool .Type .POLYGON , name = "test-polygon-class" ),
1087- Tool (tool = Tool .Type .NER , name = "test-ner-class" ),
10881081 ]
10891082
10901083 options = [
@@ -1116,7 +1109,11 @@ def configured_project_with_complex_ontology(
11161109 for c in classifications :
11171110 ontology .add_classification (c )
11181111
1119- project .setup (editor , ontology .asdict ())
1112+ ontology = client .create_ontology (
1113+ "complex image ontology" , ontology .asdict (), MediaType .Image
1114+ )
1115+
1116+ project .connect_ontology (ontology )
11201117
11211118 yield [project , data_row ]
11221119 teardown_helpers .teardown_project_labels_ontology_feature_schemas (project )
0 commit comments