Skip to content

Commit

Permalink
check for edge query
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyEWood committed Jan 15, 2025
1 parent c4abf70 commit 79f8e26
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,15 @@ def wait_for_confident_result(
confidence_threshold = self.get_detector(image_query.detector_id).confidence_threshold

confidence_above_thresh = partial(iq_is_confident, confidence_threshold=confidence_threshold) # type: ignore

def is_from_edge(iq: ImageQuery) -> bool:
return iq.metadata and iq.metadata.get("is_from_edge", False)

if is_from_edge(image_query) and not confidence_above_thresh(image_query):
# If the query is from the edge and the confidence is not above the threshold, it means the client wants
# only edge answers, so we don't want to poll the cloud.
return image_query

return self._wait_for_result(image_query, condition=confidence_above_thresh, timeout_sec=timeout_sec)

def wait_for_ml_result(self, image_query: Union[ImageQuery, str], timeout_sec: float = 30.0) -> ImageQuery:
Expand Down

0 comments on commit 79f8e26

Please sign in to comment.