File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 2525 ImageQuery ,
2626 PaginatedDetectorList ,
2727 PaginatedImageQueryList ,
28+ Source ,
2829)
2930from urllib3 .exceptions import InsecureRequestWarning
3031
@@ -969,6 +970,7 @@ def wait_for_confident_result(
969970 1. A result with confidence >= confidence_threshold is available
970971 2. The timeout_sec is reached
971972 3. An error occurs
973+ If the image query is from the edge, the result is returned immediately and not waited for.
972974
973975 **Example usage**::
974976
@@ -1002,17 +1004,13 @@ def wait_for_confident_result(
10021004 :meth:`get_image_query` for checking result status without blocking
10031005 :meth:`wait_for_ml_result` for waiting until the first ML result is available
10041006 """
1005-
1006- def is_from_edge (iq : ImageQuery ) -> bool :
1007- return iq .metadata and iq .metadata .get ("is_from_edge" , False )
1008-
1009- if is_from_edge (image_query ):
1010- # If the query is from the edge, there is nothing to wait for.
1011- logger .debug (
1012- "The image query is from the edge and the client wanted only edge answers, so we are not"
1013- " attempting to get a result from the cloud."
1014- )
1015- return image_query
1007+ if isinstance (image_query , ImageQuery ):
1008+ if image_query .result and image_query .result .source and image_query .result .source == Source .EDGE :
1009+ logger .debug (
1010+ "The image query is from the edge, so we are returning it immediately and not waiting for a "
1011+ "confident result."
1012+ )
1013+ return image_query
10161014
10171015 if isinstance (image_query , str ):
10181016 image_query = self .get_image_query (image_query )
You can’t perform that action at this time.
0 commit comments