diff --git a/.vscode/settings.json b/.vscode/settings.json index d2bafea9..01d8c0f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,10 @@ "editor.codeActionsOnSave": { "source.organizeImports": true }, + "editor.rulers": [ + 100, + 120 + ], "python.analysis.extraPaths": [ "./generated" ], diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 2b558fd7..eefedf30 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -222,8 +222,8 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments params["human_review"] = human_review if want_async is True: - # If want_async is True, we don't want to wait for a result. As a result using both wait and want_async makes - # no sense. + # If want_async is True, we don't want to wait for a result. As a result using both wait and want_async + # makes no sense. if wait is not None: raise ValueError( "wait must be None if want_async is True as the two are incompatible. Please set wait" @@ -247,6 +247,22 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments image_query = self.wait_for_confident_result(image_query, confidence_threshold=threshold, timeout_sec=wait) return self._fixup_image_query(image_query, want_async=want_async) + + def ask_async(self, + detector: Union[Detector, str], + image: Union[str, bytes, Image.Image, BytesIO, BufferedReader, np.ndarray], + human_review: Optional[str] = None, + inspection_id: Optional[str] = None) -> ImageQuery: + """ + Convenience method for submitting an image query asynchronously. This is equivalent to calling + submit_image_query with want_async=True. Use get_image_query to retrieve the result of the image query. + """ + return self.submit_image_query(detector, + image, + human_review=human_review, + want_async=True, + inspection_id=inspection_id) + def wait_for_confident_result( self,