Skip to content

Commit bafb4a6

Browse files
committed
this doesn't work because the cloud iq escalated from the edge will look the same
1 parent 12152c7 commit bafb4a6

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/groundlight/client.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,18 @@ def wait_for_confident_result(
997997
:meth:`get_image_query` for checking result status without blocking
998998
:meth:`wait_for_ml_result` for waiting until the first ML result is available
999999
"""
1000+
1001+
def is_from_edge(iq: ImageQuery) -> bool:
1002+
return iq.metadata and iq.metadata.get("is_from_edge", False)
1003+
1004+
if is_from_edge(image_query):
1005+
# If the query is from the edge, there is nothing to wait for.
1006+
logger.debug(
1007+
"The image query is from the edge and the client wanted only edge answers, so we are not"
1008+
" attempting to get a result from the cloud."
1009+
)
1010+
return image_query
1011+
10001012
if isinstance(image_query, str):
10011013
image_query = self.get_image_query(image_query)
10021014
confidence_threshold = self.get_detector(image_query.detector_id).confidence_threshold
@@ -1076,21 +1088,8 @@ def _wait_for_result(
10761088
logger.debug(f"Polling ({target_delay:.1f}/{timeout_sec:.0f}s) {image_query} until result is available")
10771089
time.sleep(sleep_time)
10781090
next_delay *= self.POLLING_EXPONENTIAL_BACKOFF
1079-
1080-
def is_from_edge(iq: ImageQuery) -> bool:
1081-
return iq.metadata and iq.metadata.get("is_from_edge", False)
1082-
1083-
if is_from_edge(image_query) and not condition(image_query):
1084-
# If the query is from the edge and the condition is not met, it means the client wanted only edge
1085-
# answers, so we don't want to poll the cloud and we should eventually return whatever the edge response
1086-
# was. We'll wait the remaining time to stay consistent with the behavior of the wait parameter.
1087-
logger.debug(
1088-
"The image query is from the edge and the client wanted only edge answers, so we are not"
1089-
" attempting to get a result from the cloud."
1090-
)
1091-
else:
1092-
image_query = self.get_image_query(image_query.id)
1093-
image_query = self._fixup_image_query(image_query)
1091+
image_query = self.get_image_query(image_query.id)
1092+
image_query = self._fixup_image_query(image_query)
10941093
return image_query
10951094

10961095
def add_label(

0 commit comments

Comments
 (0)