Skip to content

Commit

Permalink
Cleaning the lint trap
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-groundlight committed Oct 13, 2023
1 parent 10aba12 commit 88d67eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def ask_ml(
self,
detector: Union[Detector, str],
image: Union[str, bytes, Image.Image, BytesIO, BufferedReader, np.ndarray],
wait: Optional[float] = 10,
wait: Optional[float] = None,
) -> ImageQuery:
"""Evaluates an image with Groundlight, getting the first answer Groundlight can provide.
:param detector: the Detector object, or string id of a detector like `det_12345`
Expand Down Expand Up @@ -350,8 +350,8 @@ def ask_ml(
)
if iq_is_answered(iq):
return iq
else:
return self.wait_for_ml_result(iq, timeout_sec=wait)
wait = self.DEFAULT_WAIT if wait is None else wait
return self.wait_for_ml_result(iq, timeout_sec=wait)

def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments
self,
Expand Down
11 changes: 6 additions & 5 deletions test/integration/test_groundlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import pytest
from groundlight import Groundlight
from groundlight.binary_labels import VALID_DISPLAY_LABELS, DeprecatedLabel, Label, convert_internal_label_to_display
from groundlight.internalapi import InternalApiError, NotFoundError
from groundlight.internalapi import InternalApiError, NotFoundError, iq_is_answered
from groundlight.optional_imports import *
from groundlight.status_codes import is_user_error
from model import ClassificationResult, Detector, ImageQuery, PaginatedDetectorList, PaginatedImageQueryList

DEFAULT_CONFIDENCE_THRESHOLD = 0.9
IQ_IMPROVEMENT_THRESHOLD = 0.75


def is_valid_display_result(result: Any) -> bool:
Expand Down Expand Up @@ -194,7 +195,7 @@ def validate_image_query(_image_query: ImageQuery):
detector=detector.id, image="test/assets/dog.jpeg", wait=180, confidence_threshold=0.75
)
validate_image_query(_image_query)
assert _image_query.result.confidence >= 0.75
assert _image_query.result.confidence >= IQ_IMPROVEMENT_THRESHOLD


def test_submit_image_query_blocking(gl: Groundlight, detector: Detector):
Expand Down Expand Up @@ -470,14 +471,14 @@ def submit_noisy_image(image, label=None):
def test_ask_method_quality(gl: Groundlight, detector: Detector):
# asks for some level of quality on how fast ask_ml is and that we will get a confident result from ask_confident
fast_always_yes_iq = gl.ask_ml(detector=detector.id, image="test/assets/dog.jpeg", wait=0)
assert fast_always_yes_iq.result.confidence > 0.5
assert iq_is_answered(fast_always_yes_iq)
name = f"Test {datetime.utcnow()}" # Need a unique name
query = "Is there a dog?"
detector = gl.create_detector(name=name, query=query, confidence_threshold=0.8)
fast_iq = gl.ask_ml(detector=detector.id, image="test/assets/dog.jpeg", wait=0)
assert fast_iq.result.confidence > 0.5
assert iq_is_answered(fast_iq)
confident_iq = gl.ask_confident(detector=detector.id, image="test/assets/dog.jpeg", wait=180)
assert confident_iq.result.confidence > 0.8
assert confident_iq.result.confidence > IQ_IMPROVEMENT_THRESHOLD


def test_start_inspection(gl: Groundlight):
Expand Down

0 comments on commit 88d67eb

Please sign in to comment.