Skip to content

Commit 2615d43

Browse files
committed
added tests for n_ignored
1 parent 21f6c5d commit 2615d43

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

nucleus/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@
9494
DATASET_ITEM_ID_KEY,
9595
SLICE_ID_KEY,
9696
ANNOTATIONS_PROCESSED_KEY,
97+
ANNOTATIONS_IGNORED_KEY,
9798
PREDICTIONS_PROCESSED_KEY,
99+
PREDICTIONS_IGNORED_KEY,
98100
STATUS_CODE_KEY,
99101
SUCCESS_STATUS_CODES,
100102
DATASET_NAME_KEY,
@@ -482,6 +484,7 @@ def annotate_dataset(
482484
agg_response = {
483485
DATASET_ID_KEY: dataset_id,
484486
ANNOTATIONS_PROCESSED_KEY: 0,
487+
ANNOTATIONS_IGNORED_KEY: 0,
485488
}
486489

487490
tqdm_batches = self.tqdm_bar(batches)
@@ -497,6 +500,9 @@ def annotate_dataset(
497500
agg_response[ANNOTATIONS_PROCESSED_KEY] += response[
498501
ANNOTATIONS_PROCESSED_KEY
499502
]
503+
agg_response[ANNOTATIONS_IGNORED_KEY] += response[
504+
ANNOTATIONS_IGNORED_KEY
505+
]
500506

501507
return agg_response
502508

@@ -584,7 +590,8 @@ def predict(
584590
{
585591
"dataset_id": str,
586592
"model_run_id": str,
587-
"annotations_processed: int,
593+
"predictions_processed": int,
594+
"predictions_ignored": int,
588595
}
589596
"""
590597
batches = [
@@ -595,6 +602,7 @@ def predict(
595602
agg_response = {
596603
MODEL_RUN_ID_KEY: model_run_id,
597604
PREDICTIONS_PROCESSED_KEY: 0,
605+
PREDICTIONS_IGNORED_KEY: 0,
598606
}
599607

600608
tqdm_batches = self.tqdm_bar(batches)
@@ -613,6 +621,9 @@ def predict(
613621
agg_response[PREDICTIONS_PROCESSED_KEY] += response[
614622
PREDICTIONS_PROCESSED_KEY
615623
]
624+
agg_response[PREDICTIONS_IGNORED_KEY] += response[
625+
PREDICTIONS_IGNORED_KEY
626+
]
616627

617628
return agg_response
618629
# return self._make_request(payload, f"modelRun/{model_run_id}/predict")

nucleus/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
ANNOTATIONS_KEY = "annotations"
1616
ANNOTATION_ID_KEY = "annotation_id"
1717
ANNOTATIONS_PROCESSED_KEY = "annotations_processed"
18+
ANNOTATIONS_IGNORED_KEY = "annotations_ignored"
1819
PREDICTIONS_PROCESSED_KEY = "predictions_processed"
20+
PREDICTIONS_IGNORED_KEY = "predictions_ignored"
1921
ANNOTATION_UPDATE_KEY = "update"
2022
DEFAULT_ANNOTATION_UPDATE_MODE = False
2123
STATUS_CODE_KEY = "status_code"

nucleus/model_run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def predict(
7171
:return:
7272
{
7373
"model_run_id": str,
74-
"predictions_processed: int,
74+
"predictions_processed": int,
75+
"predictions_ignored": int,
7576
}
7677
"""
7778
return self._client.predict(self.model_run_id, annotations, update)

tests/test_annotation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_box_gt_upload(dataset):
3737

3838
assert response['dataset_id'] == dataset.id
3939
assert response['annotations_processed'] == 1
40+
assert response['annotations_ignored'] == 0
4041

4142
response = dataset.refloc(annotation.reference_id)['annotations']
4243
assert len(response) == 1
@@ -50,6 +51,7 @@ def test_polygon_gt_upload(dataset):
5051

5152
assert response['dataset_id'] == dataset.id
5253
assert response['annotations_processed'] == 1
54+
assert response['annotations_ignored'] == 0
5355

5456
response = dataset.refloc(annotation.reference_id)['annotations']
5557
assert len(response) == 1
@@ -72,6 +74,7 @@ def test_box_gt_upload_update(dataset):
7274
response = dataset.annotate(annotations=[annotation_update], update=True)
7375

7476
assert response['annotations_processed'] == 1
77+
assert response['annotations_ignored'] == 0
7578

7679
response = dataset.refloc(annotation.reference_id)['annotations']
7780
assert len(response) == 1
@@ -94,6 +97,7 @@ def test_box_gt_upload_ignore(dataset):
9497
response = dataset.annotate(annotations=[annotation_update])
9598

9699
assert response['annotations_processed'] == 1
100+
assert response['annotations_ignored'] == 1
97101

98102
response = dataset.refloc(annotation.reference_id)['annotations']
99103
assert len(response) == 1
@@ -116,6 +120,7 @@ def test_polygon_gt_upload_update(dataset):
116120
response = dataset.annotate(annotations=[annotation_update], update=True)
117121

118122
assert response['annotations_processed'] == 1
123+
assert response['annotations_ignored'] == 0
119124

120125
response = dataset.refloc(annotation.reference_id)['annotations']
121126
assert len(response) == 1
@@ -139,6 +144,7 @@ def test_polygon_gt_upload_ignore(dataset):
139144
response = dataset.annotate(annotations=[annotation_update])
140145

141146
assert response['annotations_processed'] == 1
147+
assert response['annotations_ignored'] == 1
142148

143149
response = dataset.refloc(annotation.reference_id)['annotations']
144150
assert len(response) == 1

tests/test_prediction.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def test_box_pred_upload(model_run):
5252

5353
assert response['model_run_id'] == model_run.model_run_id
5454
assert response['predictions_processed'] == 1
55+
assert response['predictions_ignored'] == 0
5556

5657
response = model_run.refloc(prediction.reference_id)
5758
assert len(response) == 1
@@ -63,7 +64,8 @@ def test_polygon_pred_upload(model_run):
6364
response = model_run.predict(annotations=[prediction])
6465

6566
assert response['model_run_id'] == model_run.model_run_id
66-
assert response['predictions_processed'] == 1
67+
assert response['predictions_ignored'] == 0
68+
assert response['predictions_ignored'] == 0
6769

6870
response = model_run.refloc(prediction.reference_id)
6971
assert len(response) == 1
@@ -85,6 +87,7 @@ def test_box_pred_upload_update(model_run):
8587
response = model_run.predict(annotations=[prediction_update], update=True)
8688

8789
assert response['predictions_processed'] == 1
90+
assert response['predictions_ignored'] == 0
8891

8992
response = model_run.refloc(prediction.reference_id)
9093
assert len(response) == 1
@@ -106,6 +109,7 @@ def test_box_pred_upload_ignore(model_run):
106109
response = model_run.predict(annotations=[prediction_update])
107110

108111
assert response['predictions_processed'] == 1
112+
assert response['predictions_ignored'] == 1
109113

110114
response = model_run.refloc(prediction.reference_id)
111115
assert len(response) == 1
@@ -127,6 +131,7 @@ def test_polygon_pred_upload_update(model_run):
127131
response = model_run.predict(annotations=[prediction_update], update=True)
128132

129133
assert response['predictions_processed'] == 1
134+
assert response['predictions_ignored'] == 0
130135

131136
response = model_run.refloc(prediction.reference_id)
132137
assert len(response) == 1
@@ -149,6 +154,7 @@ def test_polygon_pred_upload_ignore(model_run):
149154
response = model_run.predict(annotations=[prediction_update])
150155

151156
assert response['predictions_processed'] == 1
157+
assert response['predictions_ignored'] == 1
152158

153159
response = model_run.refloc(prediction.reference_id)
154160
assert len(response) == 1

0 commit comments

Comments
 (0)