Skip to content

Commit 414ab8f

Browse files
committed
Return operation in train_detector
1 parent 224f236 commit 414ab8f

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/picterra/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def train_detector(self, detector_id):
833833
resp = self.sess.post(self._api_url("detectors/%s/train/" % detector_id))
834834
if not resp.ok:
835835
raise APIError(resp.text)
836-
self._wait_until_operation_completes(resp.json())
836+
return self._wait_until_operation_completes(resp.json())
837837

838838
def run_advanced_tool(self, tool_id: UUID, inputs: dict, outputs: dict):
839839
"""

tests/test_client.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,9 +821,24 @@ def test_train_detector():
821821
add_mock_detector_train_responses(1)
822822
add_mock_operations_responses("running")
823823
add_mock_operations_responses("running")
824-
add_mock_operations_responses("success")
824+
add_mock_operations_responses(
825+
"success",
826+
results={
827+
"score": 92,
828+
"stats": {
829+
"rasters_count": 1,
830+
"training_areas_count": 2,
831+
"assessment_areas_count": 10,
832+
"validation_areas_count": 5,
833+
"total_annotations_count": 4,
834+
"training_annotations_count": 3,
835+
"validation_annotations_count": 1,
836+
},
837+
}
838+
)
825839
client = _client()
826-
client.train_detector(1)
840+
op = client.train_detector(1)
841+
assert op["results"]["score"] == 92
827842
assert len(responses.calls) == 4
828843

829844

0 commit comments

Comments
 (0)