1
1
from nucleus .annotation import SegmentationAnnotation
2
2
from nucleus .dataset import Dataset
3
3
from tests .helpers import (
4
+ NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET ,
4
5
TEST_LOCAL_MASK_URL ,
5
6
TEST_SEGMENTATION_ANNOTATIONS ,
6
7
assert_segmentation_annotation_matches_dict ,
@@ -38,15 +39,17 @@ def test_batch_local_semseg_gt_upload(dataset: Dataset):
38
39
request_annotation .mask_url = TEST_LOCAL_MASK_URL
39
40
response = dataset .annotate (annotations = request_annotations )
40
41
41
- print (request_annotations )
42
- print (response )
43
-
44
42
assert response ["dataset_id" ] == dataset .id
45
- assert response ["annotations_processed" ] == 4
43
+ assert (
44
+ response ["annotations_processed" ]
45
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
46
+ )
46
47
assert response ["annotations_ignored" ] == 0
47
48
assert bad_reference_id in response ["errors" ][0 ]
48
49
49
- for request_annotation in request_annotations [:4 ]:
50
+ for request_annotation in request_annotations [
51
+ :NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
52
+ ]:
50
53
response_annotation = dataset .refloc (request_annotation .reference_id )[
51
54
"annotations"
52
55
]["segmentation" ][0 ]
@@ -78,7 +81,10 @@ def test_batch_semseg_gt_upload(dataset):
78
81
]
79
82
response = dataset .annotate (annotations = annotations )
80
83
assert response ["dataset_id" ] == dataset .id
81
- assert response ["annotations_processed" ] == 4
84
+ assert (
85
+ response ["annotations_processed" ]
86
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
87
+ )
82
88
assert response ["annotations_ignored" ] == 0
83
89
84
90
@@ -90,14 +96,20 @@ def test_batch_semseg_gt_upload_ignore(dataset):
90
96
]
91
97
response = dataset .annotate (annotations = annotations )
92
98
assert response ["dataset_id" ] == dataset .id
93
- assert response ["annotations_processed" ] == 4
99
+ assert (
100
+ response ["annotations_processed" ]
101
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
102
+ )
94
103
assert response ["annotations_ignored" ] == 0
95
104
96
105
# When we re-upload, expect them to be ignored
97
106
response = dataset .annotate (annotations = annotations )
98
107
assert response ["dataset_id" ] == dataset .id
99
108
assert response ["annotations_processed" ] == 0
100
- assert response ["annotations_ignored" ] == 4
109
+ assert (
110
+ response ["annotations_ignored" ]
111
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
112
+ )
101
113
102
114
103
115
def test_batch_semseg_gt_upload_update (dataset ):
@@ -108,11 +120,17 @@ def test_batch_semseg_gt_upload_update(dataset):
108
120
]
109
121
response = dataset .annotate (annotations = annotations )
110
122
assert response ["dataset_id" ] == dataset .id
111
- assert response ["annotations_processed" ] == 4
123
+ assert (
124
+ response ["annotations_processed" ]
125
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
126
+ )
112
127
assert response ["annotations_ignored" ] == 0
113
128
114
129
# When we re-upload, expect uploads to be processed
115
130
response = dataset .annotate (annotations = annotations , update = True )
116
131
assert response ["dataset_id" ] == dataset .id
117
- assert response ["annotations_processed" ] == 4
132
+ assert (
133
+ response ["annotations_processed" ]
134
+ == NUM_VALID_SEGMENTATIONS_IN_MAIN_DATASET
135
+ )
118
136
assert response ["annotations_ignored" ] == 0
0 commit comments