@@ -656,7 +656,7 @@ def configured_project_with_label(
656
656
[data_row .uid ], # sample of data row objects
657
657
5 , # priority between 1(Highest) - 5(lowest)
658
658
)
659
- ontology = _setup_ontology (project )
659
+ ontology = _setup_ontology (project , client )
660
660
label = _create_label (
661
661
project , data_row , ontology , wait_for_label_processing
662
662
)
@@ -699,20 +699,19 @@ def create_label():
699
699
return label
700
700
701
701
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 ):
708
703
ontology_builder = OntologyBuilder (
709
704
tools = [
710
705
Tool (tool = Tool .Type .BBOX , name = "test-bbox-class" ),
711
706
]
712
707
)
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
+
716
715
return OntologyBuilder .from_project (project )
717
716
718
717
@@ -754,7 +753,7 @@ def configured_batch_project_with_label(
754
753
project .create_batch ("test-batch" , data_rows )
755
754
project .data_row_ids = data_rows
756
755
757
- ontology = _setup_ontology (project )
756
+ ontology = _setup_ontology (project , client )
758
757
label = _create_label (
759
758
project , data_row , ontology , wait_for_label_processing
760
759
)
@@ -786,7 +785,7 @@ def configured_batch_project_with_multiple_datarows(
786
785
batch_name = f"batch { uuid .uuid4 ()} "
787
786
project .create_batch (batch_name , global_keys = global_keys )
788
787
789
- ontology = _setup_ontology (project )
788
+ ontology = _setup_ontology (project , client )
790
789
for datarow in data_rows :
791
790
_create_label (project , datarow , ontology , wait_for_label_processing )
792
791
@@ -1023,11 +1022,11 @@ def _upload_invalid_data_rows_for_dataset(dataset: Dataset):
1023
1022
1024
1023
@pytest .fixture
1025
1024
def 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
1027
1026
):
1028
1027
dataset = initial_dataset
1029
1028
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
1031
1030
1032
1031
batch = project .create_batch (
1033
1032
rand_gen (str ),
@@ -1042,20 +1041,21 @@ def configured_project(
1042
1041
1043
1042
1044
1043
@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 )
1053
1053
yield project
1054
1054
1055
1055
1056
1056
@pytest .fixture
1057
1057
def 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
1059
1059
):
1060
1060
project = client .create_project (
1061
1061
name = rand_gen (str ),
@@ -1072,19 +1072,12 @@ def configured_project_with_complex_ontology(
1072
1072
)
1073
1073
project .data_row_ids = data_row_ids
1074
1074
1075
- editor = list (
1076
- project .client .get_labeling_frontends (
1077
- where = LabelingFrontend .name == "editor"
1078
- )
1079
- )[0 ]
1080
-
1081
1075
ontology = OntologyBuilder ()
1082
1076
tools = [
1083
1077
Tool (tool = Tool .Type .BBOX , name = "test-bbox-class" ),
1084
1078
Tool (tool = Tool .Type .LINE , name = "test-line-class" ),
1085
1079
Tool (tool = Tool .Type .POINT , name = "test-point-class" ),
1086
1080
Tool (tool = Tool .Type .POLYGON , name = "test-polygon-class" ),
1087
- Tool (tool = Tool .Type .NER , name = "test-ner-class" ),
1088
1081
]
1089
1082
1090
1083
options = [
@@ -1116,7 +1109,11 @@ def configured_project_with_complex_ontology(
1116
1109
for c in classifications :
1117
1110
ontology .add_classification (c )
1118
1111
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 )
1120
1117
1121
1118
yield [project , data_row ]
1122
1119
teardown_helpers .teardown_project_labels_ontology_feature_schemas (project )
0 commit comments