diff --git a/generated/docs/CountingResult.md b/generated/docs/CountingResult.md index b5f32515..c58845d8 100644 --- a/generated/docs/CountingResult.md +++ b/generated/docs/CountingResult.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**count** | **int** | | +**count** | **int, none_type** | | **confidence** | **float** | | [optional] **source** | **str** | | [optional] **greater_than_max** | **bool** | | [optional] diff --git a/generated/groundlight_openapi_client/model/counting_result.py b/generated/groundlight_openapi_client/model/counting_result.py index 774cabce..a81b49f5 100644 --- a/generated/groundlight_openapi_client/model/counting_result.py +++ b/generated/groundlight_openapi_client/model/counting_result.py @@ -104,7 +104,10 @@ def openapi_types(): and the value is attribute type. """ return { - "count": (int,), # noqa: E501 + "count": ( + int, + none_type, + ), # noqa: E501 "confidence": (float,), # noqa: E501 "source": (str,), # noqa: E501 "greater_than_max": (bool,), # noqa: E501 @@ -131,7 +134,7 @@ def _from_openapi_data(cls, count, *args, **kwargs): # noqa: E501 """CountingResult - a model defined in OpenAPI Args: - count (int): + count (int, none_type): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -222,7 +225,7 @@ def __init__(self, count, *args, **kwargs): # noqa: E501 """CountingResult - a model defined in OpenAPI Args: - count (int): + count (int, none_type): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/generated/model.py b/generated/model.py index b8f4da4a..aac94f27 100644 --- a/generated/model.py +++ b/generated/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: public-api.yaml -# timestamp: 2024-12-13T20:10:31+00:00 +# timestamp: 2024-12-19T17:53:53+00:00 from __future__ import annotations @@ -200,7 +200,7 @@ class BinaryClassificationResult(BaseModel): class CountingResult(BaseModel): confidence: Optional[confloat(ge=0.0, le=1.0)] = None source: Optional[Source] = None - count: conint(ge=0) + count: Optional[conint(ge=0)] = Field(...) greater_than_max: Optional[bool] = None diff --git a/spec/public-api.yaml b/spec/public-api.yaml index 10e8ecaa..930dc555 100644 --- a/spec/public-api.yaml +++ b/spec/public-api.yaml @@ -1381,6 +1381,7 @@ components: count: type: integer minimum: 0 + nullable: true greater_than_max: type: boolean required: diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 971551d9..0a8d4626 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -527,6 +527,9 @@ def get_image_query(self, id: str) -> ImageQuery: # pylint: disable=redefined-b :return: ImageQuery object containing the query details and results """ obj = self.image_queries_api.get_image_query(id=id, _request_timeout=DEFAULT_REQUEST_TIMEOUT) + if obj.result_type == "counting" and getattr(obj.result, "label", None): + obj.result.pop("label") + obj.result["count"] = None iq = ImageQuery.parse_obj(obj.to_dict()) return self._fixup_image_query(iq) diff --git a/test/unit/test_labels.py b/test/unit/test_labels.py index d894801d..51728503 100644 --- a/test/unit/test_labels.py +++ b/test/unit/test_labels.py @@ -25,13 +25,20 @@ def test_counting_labels(gl_experimental: ExperimentalApi): name = f"Test binary labels{datetime.utcnow()}" det = gl_experimental.create_counting_detector(name, "test_query", "test_object_class") iq1 = gl_experimental.submit_image_query(det, "test/assets/cat.jpeg") + gl_experimental.add_label(iq1, 0) iq1 = gl_experimental.get_image_query(iq1.id) assert iq1.result.count == 0 + good_label = 5 gl_experimental.add_label(iq1, good_label) iq1 = gl_experimental.get_image_query(iq1.id) assert iq1.result.count == good_label + + gl_experimental.add_label(iq1, "UNCLEAR") + iq1 = gl_experimental.get_image_query(iq1.id) + assert iq1.result.count is None + with pytest.raises(ApiException) as _: gl_experimental.add_label(iq1, "MAYBE") with pytest.raises(ApiException) as _: