Skip to content

Commit 7512c16

Browse files
author
Ubuntu
committed
Fix weird typing bug
1 parent 0295cdc commit 7512c16

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

nucleus/__init__.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,9 @@ def predict(
792792
for i in range(0, len(other_predictions), batch_size)
793793
]
794794

795-
agg_response = {
796-
MODEL_RUN_ID_KEY: model_run_id,
797-
PREDICTIONS_PROCESSED_KEY: 0,
798-
PREDICTIONS_IGNORED_KEY: 0,
799-
}
795+
errors = []
796+
predictions_processed = 0
797+
predictions_ignored = 0
800798

801799
tqdm_batches = self.tqdm_bar(batches)
802800

@@ -807,29 +805,27 @@ def predict(
807805
)
808806
response = self.make_request(batch_payload, endpoint)
809807
if STATUS_CODE_KEY in response:
810-
agg_response[ERRORS_KEY] = response
808+
errors.append(response)
811809
else:
812-
agg_response[PREDICTIONS_PROCESSED_KEY] += response[
813-
PREDICTIONS_PROCESSED_KEY
814-
]
815-
agg_response[PREDICTIONS_IGNORED_KEY] += response[
816-
PREDICTIONS_IGNORED_KEY
817-
]
810+
predictions_processed += response[PREDICTIONS_PROCESSED_KEY]
811+
predictions_ignored += response[PREDICTIONS_IGNORED_KEY]
818812

819813
for s_batch in s_batches:
820814
payload = construct_segmentation_payload(s_batch, update)
821815
response = self.make_request(payload, endpoint)
822816
# pbar.update(1)
823817
if STATUS_CODE_KEY in response:
824-
agg_response[ERRORS_KEY] = response
818+
errors.append(response)
825819
else:
826-
agg_response[PREDICTIONS_PROCESSED_KEY] += response[
827-
PREDICTIONS_PROCESSED_KEY
828-
]
829-
agg_response[PREDICTIONS_IGNORED_KEY] += response[
830-
PREDICTIONS_IGNORED_KEY
831-
]
820+
predictions_processed += response[PREDICTIONS_PROCESSED_KEY]
821+
predictions_ignored += response[PREDICTIONS_IGNORED_KEY]
832822

823+
agg_response = {
824+
MODEL_RUN_ID_KEY: model_run_id,
825+
PREDICTIONS_PROCESSED_KEY: predictions_ignored,
826+
PREDICTIONS_IGNORED_KEY: predictions_processed,
827+
ERRORS_KEY: errors,
828+
}
833829
return agg_response
834830

835831
def commit_model_run(

nucleus/model.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Optional, Dict, Type, Union
1+
from typing import List, Optional, Dict, Union
22
from .dataset import Dataset
33
from .prediction import (
44
BoxPrediction,
@@ -8,14 +8,9 @@
88
)
99
from .model_run import ModelRun
1010
from .constants import (
11-
ANNOTATIONS_KEY,
12-
BOX_TYPE,
13-
CUBOID_TYPE,
1411
NAME_KEY,
15-
POLYGON_TYPE,
1612
REFERENCE_ID_KEY,
1713
METADATA_KEY,
18-
SEGMENTATION_TYPE,
1914
)
2015

2116

0 commit comments

Comments
 (0)