Skip to content

Commit 2004b65

Browse files
brandon-wadaAuto-format Bot
andauthored
add small test for async counting (#311)
Co-authored-by: Auto-format Bot <autoformatbot@groundlight.ai>
1 parent 2eceb62 commit 2004b65

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/unit/test_experimental.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
from datetime import datetime
23

34
import pytest
@@ -106,6 +107,25 @@ def test_counting_detector(gl_experimental: ExperimentalApi):
106107
assert count_iq.result.count is not None
107108

108109

110+
def test_counting_detector_async(gl_experimental: ExperimentalApi):
111+
"""
112+
verify that we can create and submit to a counting detector
113+
"""
114+
name = f"Test {datetime.utcnow()}"
115+
created_detector = gl_experimental.create_counting_detector(name, "How many dogs", "dog")
116+
assert created_detector is not None
117+
async_iq = gl_experimental.ask_async(created_detector, "test/assets/dog.jpeg")
118+
# attempting to access fields within the result should raise an exception
119+
with pytest.raises(AttributeError):
120+
_ = async_iq.result.label # type: ignore
121+
with pytest.raises(AttributeError):
122+
_ = async_iq.result.confidence # type: ignore
123+
time.sleep(5)
124+
# you should be able to get a "real" result by retrieving an updated image query object from the server
125+
_image_query = gl_experimental.get_image_query(id=async_iq.id)
126+
assert _image_query.result is not None
127+
128+
109129
@pytest.mark.skip(
110130
reason=(
111131
"General users currently currently can't use multiclass detectors. If you have questions, reach out"

0 commit comments

Comments
 (0)