From b9d435fb6203f2370dd9d380ec666baca7db4924 Mon Sep 17 00:00:00 2001 From: brandon Date: Mon, 27 Jan 2025 09:40:37 -0800 Subject: [PATCH 1/2] add small test for async counting --- test/unit/test_experimental.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unit/test_experimental.py b/test/unit/test_experimental.py index b0dca6a2..712550de 100644 --- a/test/unit/test_experimental.py +++ b/test/unit/test_experimental.py @@ -1,4 +1,5 @@ from datetime import datetime +import time import pytest from groundlight import ExperimentalApi @@ -106,6 +107,26 @@ def test_counting_detector(gl_experimental: ExperimentalApi): assert count_iq.result.count is not None +def test_counting_detector_async(gl_experimental: ExperimentalApi): + """ + verify that we can create and submit to a counting detector + """ + name = f"Test {datetime.utcnow()}" + created_detector = gl_experimental.create_counting_detector(name, "How many dogs", "dog") + assert created_detector is not None + async_iq = gl_experimental.ask_async(created_detector, "test/assets/dog.jpeg") + # attempting to access fields within the result should raise an exception + with pytest.raises(AttributeError): + _ = async_iq.result.label # type: ignore + with pytest.raises(AttributeError): + _ = async_iq.result.confidence # type: ignore + time.sleep(5) + # you should be able to get a "real" result by retrieving an updated image query object from the server + _image_query = gl_experimental.get_image_query(id=async_iq.id) + assert _image_query.result is not None + + + @pytest.mark.skip( reason=( "General users currently currently can't use multiclass detectors. If you have questions, reach out" From e6aa813c89b5eaf715c2f5e458357e503829cd48 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Mon, 27 Jan 2025 17:41:46 +0000 Subject: [PATCH 2/2] Automatically reformatting code --- test/unit/test_experimental.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unit/test_experimental.py b/test/unit/test_experimental.py index 712550de..2dacdccc 100644 --- a/test/unit/test_experimental.py +++ b/test/unit/test_experimental.py @@ -1,5 +1,5 @@ -from datetime import datetime import time +from datetime import datetime import pytest from groundlight import ExperimentalApi @@ -126,7 +126,6 @@ def test_counting_detector_async(gl_experimental: ExperimentalApi): assert _image_query.result is not None - @pytest.mark.skip( reason=( "General users currently currently can't use multiclass detectors. If you have questions, reach out"