Skip to content

Commit 55dd26c

Browse files
author
brandon
committed
makes create_detector generic
1 parent a31fd78 commit 55dd26c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/groundlight/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
from groundlight_openapi_client.api.user_api import UserApi
1616
from groundlight_openapi_client.exceptions import NotFoundException, UnauthorizedException
1717
from groundlight_openapi_client.model.b_box_geometry_request import BBoxGeometryRequest
18+
from groundlight_openapi_client.model.count_mode_configuration import CountModeConfiguration
1819
from groundlight_openapi_client.model.detector_creation_input_request import DetectorCreationInputRequest
1920
from groundlight_openapi_client.model.label_value_request import LabelValueRequest
21+
from groundlight_openapi_client.model.multi_class_mode_configuration import MultiClassModeConfiguration
2022
from groundlight_openapi_client.model.patched_detector_request import PatchedDetectorRequest
2123
from groundlight_openapi_client.model.roi_request import ROIRequest
2224
from model import (
2325
ROI,
2426
BinaryClassificationResult,
25-
CountModeConfiguration,
2627
Detector,
2728
DetectorGroup,
2829
ImageQuery,
2930
ModeEnum,
30-
MultiClassModeConfiguration,
3131
PaginatedDetectorList,
3232
PaginatedImageQueryList,
3333
)
@@ -1524,7 +1524,7 @@ def create_counting_detector( # noqa: PLR0913 # pylint: disable=too-many-argume
15241524
if max_count is None:
15251525
mode_config = CountModeConfiguration(class_name=class_name)
15261526
else:
1527-
mode_config = CountModeConfiguration(max_count=max_count, class_name=class_name)
1527+
mode_config = CountModeConfiguration(class_name=class_name, max_count=max_count)
15281528

15291529
detector_creation_input.mode_configuration = mode_config
15301530
obj = self.detectors_api.create_detector(detector_creation_input, _request_timeout=DEFAULT_REQUEST_TIMEOUT)

test/integration/test_groundlight.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ def test_create_detector(gl: Groundlight):
8989
), "We expected the default confidence threshold to be used."
9090

9191
# Test creating dectors with other modes
92+
name = f"Test {datetime.utcnow()}" # Need a unique name
9293
count_detector = gl.create_detector(name=name, query=query, mode=ModeEnum.COUNT, class_names="dog")
9394
assert str(count_detector)
95+
name = f"Test {datetime.utcnow()}" # Need a unique name
9496
multiclass_detector = gl.create_detector(name=name, query=query, mode=ModeEnum.MULTI_CLASS, class_names=["dog", "cat"])
9597
assert str(multiclass_detector)
9698

@@ -790,13 +792,13 @@ def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector:
790792

791793
def test_binary_detector(gl: Groundlight):
792794
"""
793-
verify that we can create and submit to a counting detector
795+
verify that we can create and submit to a binary detector
794796
"""
795797
name = f"Test {datetime.utcnow()}"
796798
created_detector = gl.create_binary_detector(name, "Is there a dog", "dog", confidence_threshold=0.0)
797799
assert created_detector is not None
798-
count_iq = gl.submit_image_query(created_detector, "test/assets/dog.jpeg")
799-
assert count_iq.result.label is not None
800+
binary_iq = gl.submit_image_query(created_detector, "test/assets/dog.jpeg")
801+
assert binary_iq.result.label is not None
800802

801803
def test_counting_detector(gl: Groundlight):
802804
"""

0 commit comments

Comments
 (0)