diff --git a/generated/docs/ImageQueriesApi.md b/generated/docs/ImageQueriesApi.md index 47a65ae5..3d405374 100644 --- a/generated/docs/ImageQueriesApi.md +++ b/generated/docs/ImageQueriesApi.md @@ -203,12 +203,12 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: api_instance = image_queries_api.ImageQueriesApi(api_client) page = 1 # int | A page number within the paginated result set. (optional) page_size = 1 # int | Number of items to return per page. (optional) - predictor_id = "predictor_id_example" # str | Optionally filter image queries by detector ID. (optional) + detector_id = "detector_id_example" # str | Optionally filter image queries by detector ID. (optional) # example passing only required values which don't have defaults set # and optional values try: - api_response = api_instance.list_image_queries(page=page, page_size=page_size, predictor_id=predictor_id) + api_response = api_instance.list_image_queries(page=page, page_size=page_size, detector_id=detector_id) pprint(api_response) except groundlight_openapi_client.ApiException as e: print("Exception when calling ImageQueriesApi->list_image_queries: %s\n" % e) @@ -221,7 +221,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **page** | **int**| A page number within the paginated result set. | [optional] **page_size** | **int**| Number of items to return per page. | [optional] - **predictor_id** | **str**| Optionally filter image queries by detector ID. | [optional] + **detector_id** | **str**| Optionally filter image queries by detector ID. | [optional] ### Return type diff --git a/generated/groundlight_openapi_client/api/image_queries_api.py b/generated/groundlight_openapi_client/api/image_queries_api.py index b25ad772..906bb202 100644 --- a/generated/groundlight_openapi_client/api/image_queries_api.py +++ b/generated/groundlight_openapi_client/api/image_queries_api.py @@ -129,7 +129,7 @@ def __init__(self, api_client=None): "all": [ "page", "page_size", - "predictor_id", + "detector_id", ], "required": [], "nullable": [], @@ -142,17 +142,17 @@ def __init__(self, api_client=None): "openapi_types": { "page": (int,), "page_size": (int,), - "predictor_id": (str,), + "detector_id": (str,), }, "attribute_map": { "page": "page", "page_size": "page_size", - "predictor_id": "predictor_id", + "detector_id": "detector_id", }, "location_map": { "page": "query", "page_size": "query", - "predictor_id": "query", + "detector_id": "query", }, "collection_format_map": {}, }, @@ -379,7 +379,7 @@ def list_image_queries(self, **kwargs): Keyword Args: page (int): A page number within the paginated result set.. [optional] page_size (int): Number of items to return per page.. [optional] - predictor_id (str): Optionally filter image queries by detector ID.. [optional] + detector_id (str): Optionally filter image queries by detector ID.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object diff --git a/generated/model.py b/generated/model.py index 827e7ea1..b8f4da4a 100644 --- a/generated/model.py +++ b/generated/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: public-api.yaml -# timestamp: 2024-12-10T01:13:13+00:00 +# timestamp: 2024-12-13T20:10:31+00:00 from __future__ import annotations diff --git a/spec/public-api.yaml b/spec/public-api.yaml index 89f9f0c0..10e8ecaa 100644 --- a/spec/public-api.yaml +++ b/spec/public-api.yaml @@ -323,6 +323,11 @@ paths: schema: type: integer description: Number of items to return per page. + - in: query + name: detector_id + schema: + type: string + description: Optionally filter image queries by detector ID. tags: - image-queries security: @@ -1457,4 +1462,4 @@ servers: - url: https://device.positronix.ai/device-api description: Device Prod - url: https://device.integ.positronix.ai/device-api - description: Device Integ \ No newline at end of file + description: Device Integ diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 9cd4107d..971551d9 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -5,7 +5,7 @@ import warnings from functools import partial from io import BufferedReader, BytesIO -from typing import Callable, List, Optional, Union +from typing import Any, Callable, List, Optional, Union from groundlight_openapi_client import Configuration from groundlight_openapi_client.api.detectors_api import DetectorsApi @@ -530,7 +530,9 @@ def get_image_query(self, id: str) -> ImageQuery: # pylint: disable=redefined-b iq = ImageQuery.parse_obj(obj.to_dict()) return self._fixup_image_query(iq) - def list_image_queries(self, page: int = 1, page_size: int = 10) -> PaginatedImageQueryList: + def list_image_queries( + self, page: int = 1, page_size: int = 10, detector_id: Union[str, None] = None + ) -> PaginatedImageQueryList: """ List all image queries associated with your account, with pagination support. @@ -552,9 +554,10 @@ def list_image_queries(self, page: int = 1, page_size: int = 10) -> PaginatedIma :return: PaginatedImageQueryList containing the requested page of image queries and pagination metadata like total count and links to next/previous pages. """ - obj = self.image_queries_api.list_image_queries( - page=page, page_size=page_size, _request_timeout=DEFAULT_REQUEST_TIMEOUT - ) + params: dict[str, Any] = {"page": page, "page_size": page_size, "_request_timeout": DEFAULT_REQUEST_TIMEOUT} + if detector_id: + params["detector_id"] = detector_id + obj = self.image_queries_api.list_image_queries(**params) image_queries = PaginatedImageQueryList.parse_obj(obj.to_dict()) if image_queries.results is not None: image_queries.results = [self._fixup_image_query(iq) for iq in image_queries.results] diff --git a/test/integration/test_groundlight.py b/test/integration/test_groundlight.py index 3e183263..e344f784 100644 --- a/test/integration/test_groundlight.py +++ b/test/integration/test_groundlight.py @@ -581,6 +581,20 @@ def test_list_image_queries(gl: Groundlight): assert is_valid_display_result(image_query.result) +def test_list_image_queries_with_filter(gl: Groundlight): + # We want a fresh detector so we know exactly what image queries are associated with it + detector = gl.create_detector(name=f"Test {datetime.utcnow()}", query="Is there a dog?") + image_query_yes = gl.ask_async(detector=detector.id, image="test/assets/dog.jpeg", human_review="NEVER") + image_query_no = gl.ask_async(detector=detector.id, image="test/assets/cat.jpeg", human_review="NEVER") + iq_ids = [image_query_yes.id, image_query_no.id] + + image_queries = gl.list_image_queries(detector_id=detector.id) + num_image_queries = 2 + assert len(image_queries.results) == num_image_queries + for image_query in image_queries.results: + assert image_query.id in iq_ids + + def test_get_image_query(gl: Groundlight, image_query_yes: ImageQuery): _image_query = gl.get_image_query(id=image_query_yes.id) assert str(_image_query)