From 88050ad718fd7b1c11e3729aeec009d71462010c Mon Sep 17 00:00:00 2001 From: brandon Date: Wed, 8 Jan 2025 13:51:14 -0800 Subject: [PATCH 1/2] adds the ability to pin a note --- generated/docs/ActionsApi.md | 12 ++++++ generated/docs/BinaryClassificationResult.md | 2 +- generated/docs/CountingResult.md | 4 +- generated/docs/ImageQueriesApi.md | 6 +-- generated/docs/MultiClassificationResult.md | 2 +- generated/docs/Note.md | 3 +- generated/docs/NoteRequest.md | 3 +- generated/docs/NotesApi.md | 20 ++++++--- .../api/actions_api.py | 10 +++++ .../api/image_queries_api.py | 10 ++--- .../api/notes_api.py | 12 +++--- .../model/binary_classification_result.py | 9 ++-- .../model/counting_result.py | 18 +++++--- .../model/multi_classification_result.py | 9 ++-- .../groundlight_openapi_client/model/note.py | 23 +++++++---- .../model/note_request.py | 32 +++++++-------- generated/model.py | 10 +++-- spec/public-api.yaml | 41 +++++++++++++------ src/groundlight/experimental_api.py | 5 ++- test/unit/test_notes.py | 12 ++++++ 20 files changed, 161 insertions(+), 82 deletions(-) diff --git a/generated/docs/ActionsApi.md b/generated/docs/ActionsApi.md index f1d5b017..306424fb 100644 --- a/generated/docs/ActionsApi.md +++ b/generated/docs/ActionsApi.md @@ -296,6 +296,8 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = actions_api.ActionsApi(api_client) detector_id = "detector_id_example" # str | + page = 1 # int | A page number within the paginated result set. (optional) + page_size = 1 # int | Number of results to return per page. (optional) # example passing only required values which don't have defaults set try: @@ -303,6 +305,14 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: pprint(api_response) except groundlight_openapi_client.ApiException as e: print("Exception when calling ActionsApi->list_detector_rules: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_response = api_instance.list_detector_rules(detector_id, page=page, page_size=page_size) + pprint(api_response) + except groundlight_openapi_client.ApiException as e: + print("Exception when calling ActionsApi->list_detector_rules: %s\n" % e) ``` @@ -311,6 +321,8 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **detector_id** | **str**| | + **page** | **int**| A page number within the paginated result set. | [optional] + **page_size** | **int**| Number of results to return per page. | [optional] ### Return type diff --git a/generated/docs/BinaryClassificationResult.md b/generated/docs/BinaryClassificationResult.md index f8dc4656..40cf272e 100644 --- a/generated/docs/BinaryClassificationResult.md +++ b/generated/docs/BinaryClassificationResult.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **label** | **str** | | -**confidence** | **float** | | [optional] +**confidence** | **float, none_type** | | [optional] **source** | **str** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] diff --git a/generated/docs/CountingResult.md b/generated/docs/CountingResult.md index b5f32515..3af68072 100644 --- a/generated/docs/CountingResult.md +++ b/generated/docs/CountingResult.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**count** | **int** | | -**confidence** | **float** | | [optional] +**count** | **int, none_type** | | +**confidence** | **float, none_type** | | [optional] **source** | **str** | | [optional] **greater_than_max** | **bool** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] diff --git a/generated/docs/ImageQueriesApi.md b/generated/docs/ImageQueriesApi.md index 3d405374..e3f91416 100644 --- a/generated/docs/ImageQueriesApi.md +++ b/generated/docs/ImageQueriesApi.md @@ -201,14 +201,14 @@ configuration.api_key['ApiToken'] = 'YOUR_API_KEY' with groundlight_openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = image_queries_api.ImageQueriesApi(api_client) + detector_id = "detector_id_example" # str | Optionally filter image queries by detector ID. (optional) page = 1 # int | A page number within the paginated result set. (optional) page_size = 1 # int | Number of items to return per page. (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, detector_id=detector_id) + api_response = api_instance.list_image_queries(detector_id=detector_id, page=page, page_size=page_size) pprint(api_response) except groundlight_openapi_client.ApiException as e: print("Exception when calling ImageQueriesApi->list_image_queries: %s\n" % e) @@ -219,9 +219,9 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + **detector_id** | **str**| Optionally filter image queries by detector ID. | [optional] **page** | **int**| A page number within the paginated result set. | [optional] **page_size** | **int**| Number of items to return per page. | [optional] - **detector_id** | **str**| Optionally filter image queries by detector ID. | [optional] ### Return type diff --git a/generated/docs/MultiClassificationResult.md b/generated/docs/MultiClassificationResult.md index 4f401a3d..5bd3cfc4 100644 --- a/generated/docs/MultiClassificationResult.md +++ b/generated/docs/MultiClassificationResult.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **label** | **str** | | -**confidence** | **float** | | [optional] +**confidence** | **float, none_type** | | [optional] **source** | **str** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] diff --git a/generated/docs/Note.md b/generated/docs/Note.md index baaad6ad..a5e80378 100644 --- a/generated/docs/Note.md +++ b/generated/docs/Note.md @@ -5,7 +5,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **detector_id** | **str** | | [readonly] -**content** | **str** | Text content of the note. | +**content** | **str, none_type** | Text content of the note. | [optional] +**is_pinned** | **bool, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/generated/docs/NoteRequest.md b/generated/docs/NoteRequest.md index 4410b952..783cb431 100644 --- a/generated/docs/NoteRequest.md +++ b/generated/docs/NoteRequest.md @@ -4,7 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**content** | **str** | Text content of the note. | +**content** | **str, none_type** | Text content of the note. | [optional] +**is_pinned** | **bool, none_type** | | [optional] **image** | **file_type, none_type** | | [optional] **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] diff --git a/generated/docs/NotesApi.md b/generated/docs/NotesApi.md index 877f4f8b..f4e20739 100644 --- a/generated/docs/NotesApi.md +++ b/generated/docs/NotesApi.md @@ -9,11 +9,11 @@ Method | HTTP request | Description # **create_note** -> create_note(detector_id, note_request) +> create_note(detector_id) -Create a new note +Creates a new note. ### Example @@ -49,12 +49,20 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: detector_id = "detector_id_example" # str | the detector to associate the new note with note_request = NoteRequest( content="content_example", + is_pinned=True, image=open('/path/to/file', 'rb'), - ) # NoteRequest | + ) # NoteRequest | (optional) # example passing only required values which don't have defaults set try: - api_instance.create_note(detector_id, note_request) + api_instance.create_note(detector_id) + except groundlight_openapi_client.ApiException as e: + print("Exception when calling NotesApi->create_note: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_instance.create_note(detector_id, note_request=note_request) except groundlight_openapi_client.ApiException as e: print("Exception when calling NotesApi->create_note: %s\n" % e) ``` @@ -65,7 +73,7 @@ with groundlight_openapi_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **detector_id** | **str**| the detector to associate the new note with | - **note_request** | [**NoteRequest**](NoteRequest.md)| | + **note_request** | [**NoteRequest**](NoteRequest.md)| | [optional] ### Return type @@ -94,7 +102,7 @@ void (empty response body) -Get all the notes from a given detector and return the answer in lists, one for each note_category +Retrieves all notes from a given detector and returns them in lists, one for each note_category. ### Example diff --git a/generated/groundlight_openapi_client/api/actions_api.py b/generated/groundlight_openapi_client/api/actions_api.py index 47ac8d0d..4f9d42f5 100644 --- a/generated/groundlight_openapi_client/api/actions_api.py +++ b/generated/groundlight_openapi_client/api/actions_api.py @@ -173,6 +173,8 @@ def __init__(self, api_client=None): params_map={ "all": [ "detector_id", + "page", + "page_size", ], "required": [ "detector_id", @@ -186,12 +188,18 @@ def __init__(self, api_client=None): "allowed_values": {}, "openapi_types": { "detector_id": (str,), + "page": (int,), + "page_size": (int,), }, "attribute_map": { "detector_id": "detector_id", + "page": "page", + "page_size": "page_size", }, "location_map": { "detector_id": "path", + "page": "query", + "page_size": "query", }, "collection_format_map": {}, }, @@ -434,6 +442,8 @@ def list_detector_rules(self, detector_id, **kwargs): detector_id (str): Keyword Args: + page (int): A page number within the paginated result set.. [optional] + page_size (int): Number of results to return per page.. [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/groundlight_openapi_client/api/image_queries_api.py b/generated/groundlight_openapi_client/api/image_queries_api.py index 906bb202..03ad2600 100644 --- a/generated/groundlight_openapi_client/api/image_queries_api.py +++ b/generated/groundlight_openapi_client/api/image_queries_api.py @@ -127,9 +127,9 @@ def __init__(self, api_client=None): }, params_map={ "all": [ + "detector_id", "page", "page_size", - "detector_id", ], "required": [], "nullable": [], @@ -140,19 +140,19 @@ def __init__(self, api_client=None): "validations": {}, "allowed_values": {}, "openapi_types": { + "detector_id": (str,), "page": (int,), "page_size": (int,), - "detector_id": (str,), }, "attribute_map": { + "detector_id": "detector_id", "page": "page", "page_size": "page_size", - "detector_id": "detector_id", }, "location_map": { + "detector_id": "query", "page": "query", "page_size": "query", - "detector_id": "query", }, "collection_format_map": {}, }, @@ -377,9 +377,9 @@ def list_image_queries(self, **kwargs): Keyword Args: + detector_id (str): Optionally filter image queries by detector ID.. [optional] page (int): A page number within the paginated result set.. [optional] page_size (int): Number of items to return per page.. [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/groundlight_openapi_client/api/notes_api.py b/generated/groundlight_openapi_client/api/notes_api.py index f6522e04..f1af2cb5 100644 --- a/generated/groundlight_openapi_client/api/notes_api.py +++ b/generated/groundlight_openapi_client/api/notes_api.py @@ -52,7 +52,6 @@ def __init__(self, api_client=None): ], "required": [ "detector_id", - "note_request", ], "nullable": [], "enum": [], @@ -121,21 +120,21 @@ def __init__(self, api_client=None): api_client=api_client, ) - def create_note(self, detector_id, note_request, **kwargs): + def create_note(self, detector_id, **kwargs): """create_note # noqa: E501 - Create a new note # noqa: E501 + Creates a new note. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_note(detector_id, note_request, async_req=True) + >>> thread = api.create_note(detector_id, async_req=True) >>> result = thread.get() Args: detector_id (str): the detector to associate the new note with - note_request (NoteRequest): Keyword Args: + note_request (NoteRequest): [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 @@ -178,13 +177,12 @@ def create_note(self, detector_id, note_request, **kwargs): kwargs["_content_type"] = kwargs.get("_content_type") kwargs["_host_index"] = kwargs.get("_host_index") kwargs["detector_id"] = detector_id - kwargs["note_request"] = note_request return self.create_note_endpoint.call_with_http_info(**kwargs) def get_notes(self, detector_id, **kwargs): """get_notes # noqa: E501 - Get all the notes from a given detector and return the answer in lists, one for each note_category # noqa: E501 + Retrieves all notes from a given detector and returns them in lists, one for each note_category. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True diff --git a/generated/groundlight_openapi_client/model/binary_classification_result.py b/generated/groundlight_openapi_client/model/binary_classification_result.py index b9cd17eb..d4f5ebc4 100644 --- a/generated/groundlight_openapi_client/model/binary_classification_result.py +++ b/generated/groundlight_openapi_client/model/binary_classification_result.py @@ -107,7 +107,10 @@ def openapi_types(): """ return { "label": (str,), # noqa: E501 - "confidence": (float,), # noqa: E501 + "confidence": ( + float, + none_type, + ), # noqa: E501 "source": (str,), # noqa: E501 } @@ -164,7 +167,7 @@ def _from_openapi_data(cls, label, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 """ @@ -254,7 +257,7 @@ def __init__(self, label, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 """ diff --git a/generated/groundlight_openapi_client/model/counting_result.py b/generated/groundlight_openapi_client/model/counting_result.py index 774cabce..953a1acf 100644 --- a/generated/groundlight_openapi_client/model/counting_result.py +++ b/generated/groundlight_openapi_client/model/counting_result.py @@ -104,8 +104,14 @@ def openapi_types(): and the value is attribute type. """ return { - "count": (int,), # noqa: E501 - "confidence": (float,), # noqa: E501 + "count": ( + int, + none_type, + ), # noqa: E501 + "confidence": ( + float, + none_type, + ), # noqa: E501 "source": (str,), # noqa: E501 "greater_than_max": (bool,), # noqa: E501 } @@ -131,7 +137,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 @@ -164,7 +170,7 @@ def _from_openapi_data(cls, count, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 greater_than_max (bool): [optional] # noqa: E501 """ @@ -222,7 +228,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 @@ -255,7 +261,7 @@ def __init__(self, count, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 greater_than_max (bool): [optional] # noqa: E501 """ diff --git a/generated/groundlight_openapi_client/model/multi_classification_result.py b/generated/groundlight_openapi_client/model/multi_classification_result.py index e3e99760..177574a7 100644 --- a/generated/groundlight_openapi_client/model/multi_classification_result.py +++ b/generated/groundlight_openapi_client/model/multi_classification_result.py @@ -102,7 +102,10 @@ def openapi_types(): """ return { "label": (str,), # noqa: E501 - "confidence": (float,), # noqa: E501 + "confidence": ( + float, + none_type, + ), # noqa: E501 "source": (str,), # noqa: E501 } @@ -159,7 +162,7 @@ def _from_openapi_data(cls, label, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 """ @@ -249,7 +252,7 @@ def __init__(self, label, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - confidence (float): [optional] # noqa: E501 + confidence (float, none_type): [optional] # noqa: E501 source (str): [optional] # noqa: E501 """ diff --git a/generated/groundlight_openapi_client/model/note.py b/generated/groundlight_openapi_client/model/note.py index 91b565c4..64f139a7 100644 --- a/generated/groundlight_openapi_client/model/note.py +++ b/generated/groundlight_openapi_client/model/note.py @@ -89,7 +89,14 @@ def openapi_types(): """ return { "detector_id": (str,), # noqa: E501 - "content": (str,), # noqa: E501 + "content": ( + str, + none_type, + ), # noqa: E501 + "is_pinned": ( + bool, + none_type, + ), # noqa: E501 } @cached_property @@ -99,6 +106,7 @@ def discriminator(): attribute_map = { "detector_id": "detector_id", # noqa: E501 "content": "content", # noqa: E501 + "is_pinned": "is_pinned", # noqa: E501 } read_only_vars = { @@ -109,12 +117,11 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, detector_id, content, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, detector_id, *args, **kwargs): # noqa: E501 """Note - a model defined in OpenAPI Args: detector_id (str): - content (str): Text content of the note. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -147,6 +154,8 @@ def _from_openapi_data(cls, detector_id, content, *args, **kwargs): # noqa: E50 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + content (str, none_type): Text content of the note.. [optional] # noqa: E501 + is_pinned (bool, none_type): [optional] # noqa: E501 """ _check_type = kwargs.pop("_check_type", True) @@ -176,7 +185,6 @@ def _from_openapi_data(cls, detector_id, content, *args, **kwargs): # noqa: E50 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.detector_id = detector_id - self.content = content for var_name, var_value in kwargs.items(): if ( var_name not in self.attribute_map @@ -199,11 +207,9 @@ def _from_openapi_data(cls, detector_id, content, *args, **kwargs): # noqa: E50 ]) @convert_js_args_to_python_args - def __init__(self, content, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """Note - a model defined in OpenAPI - content (str): Text content of the note. - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -235,6 +241,8 @@ def __init__(self, content, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + content (str, none_type): Text content of the note.. [optional] # noqa: E501 + is_pinned (bool, none_type): [optional] # noqa: E501 """ _check_type = kwargs.pop("_check_type", True) @@ -261,7 +269,6 @@ def __init__(self, content, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - self.content = content for var_name, var_value in kwargs.items(): if ( var_name not in self.attribute_map diff --git a/generated/groundlight_openapi_client/model/note_request.py b/generated/groundlight_openapi_client/model/note_request.py index 09e4fe5d..95889010 100644 --- a/generated/groundlight_openapi_client/model/note_request.py +++ b/generated/groundlight_openapi_client/model/note_request.py @@ -55,11 +55,7 @@ class NoteRequest(ModelNormal): allowed_values = {} - validations = { - ("content",): { - "min_length": 1, - }, - } + validations = {} @cached_property def additional_properties_type(): @@ -92,7 +88,14 @@ def openapi_types(): and the value is attribute type. """ return { - "content": (str,), # noqa: E501 + "content": ( + str, + none_type, + ), # noqa: E501 + "is_pinned": ( + bool, + none_type, + ), # noqa: E501 "image": ( file_type, none_type, @@ -105,6 +108,7 @@ def discriminator(): attribute_map = { "content": "content", # noqa: E501 + "is_pinned": "is_pinned", # noqa: E501 "image": "image", # noqa: E501 } @@ -114,12 +118,9 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, content, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 """NoteRequest - a model defined in OpenAPI - Args: - content (str): Text content of the note. - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -151,6 +152,8 @@ def _from_openapi_data(cls, content, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + content (str, none_type): Text content of the note.. [optional] # noqa: E501 + is_pinned (bool, none_type): [optional] # noqa: E501 image (file_type, none_type): [optional] # noqa: E501 """ @@ -180,7 +183,6 @@ def _from_openapi_data(cls, content, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - self.content = content for var_name, var_value in kwargs.items(): if ( var_name not in self.attribute_map @@ -203,12 +205,9 @@ def _from_openapi_data(cls, content, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, content, *args, **kwargs): # noqa: E501 + def __init__(self, *args, **kwargs): # noqa: E501 """NoteRequest - a model defined in OpenAPI - Args: - content (str): Text content of the note. - Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -240,6 +239,8 @@ def __init__(self, content, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + content (str, none_type): Text content of the note.. [optional] # noqa: E501 + is_pinned (bool, none_type): [optional] # noqa: E501 image (file_type, none_type): [optional] # noqa: E501 """ @@ -267,7 +268,6 @@ def __init__(self, content, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - self.content = content for var_name, var_value in kwargs.items(): if ( var_name not in self.attribute_map diff --git a/generated/model.py b/generated/model.py index b8f4da4a..70225470 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: 2025-01-08T19:24:06+00:00 from __future__ import annotations @@ -84,11 +84,13 @@ class ModeEnum(str, Enum): class Note(BaseModel): detector_id: str - content: str = Field(..., description="Text content of the note.") + content: Optional[str] = Field(None, description="Text content of the note.") + is_pinned: Optional[bool] = None class NoteRequest(BaseModel): - content: constr(min_length=1) = Field(..., description="Text content of the note.") + content: Optional[str] = Field(None, description="Text content of the note.") + is_pinned: Optional[bool] = None image: Optional[bytes] = None @@ -200,7 +202,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..531d823d 100644 --- a/spec/public-api.yaml +++ b/spec/public-api.yaml @@ -19,6 +19,18 @@ paths: schema: type: string required: true + - name: page + required: false + in: query + description: A page number within the paginated result set. + schema: + type: integer + - name: page_size + required: false + in: query + description: Number of results to return per page. + schema: + type: integer tags: - actions security: @@ -313,6 +325,11 @@ paths: operationId: List image queries description: Retrieve a list of image-queries. parameters: + - in: query + name: detector_id + schema: + type: string + description: Optionally filter image queries by detector ID. - in: query name: page schema: @@ -323,11 +340,6 @@ 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: @@ -540,8 +552,8 @@ paths: /v1/notes: get: operationId: get notes - description: Get all the notes from a given detector and return the answer in - lists, one for each note_category + description: Retrieves all notes from a given detector and returns them in lists, + one for each note_category. parameters: - in: query name: detector_id @@ -562,7 +574,7 @@ paths: description: '' post: operationId: Create note - description: Create a new note + description: Creates a new note. parameters: - in: query name: detector_id @@ -583,7 +595,6 @@ paths: multipart/form-data: schema: $ref: '#/components/schemas/NoteRequest' - required: true security: - ApiToken: [] responses: @@ -1046,24 +1057,28 @@ components: readOnly: true content: type: string + nullable: true description: Text content of the note. + is_pinned: + type: boolean + nullable: true required: - - content - detector_id NoteRequest: type: object properties: content: type: string - minLength: 1 + nullable: true description: Text content of the note. + is_pinned: + type: boolean + nullable: true image: type: string format: binary writeOnly: true nullable: true - required: - - content PaginatedDetectorList: type: object required: diff --git a/src/groundlight/experimental_api.py b/src/groundlight/experimental_api.py index 5b8765b8..fb03be52 100644 --- a/src/groundlight/experimental_api.py +++ b/src/groundlight/experimental_api.py @@ -355,8 +355,9 @@ def get_notes(self, detector: Union[str, Detector]) -> Dict[str, Any]: def create_note( self, detector: Union[str, Detector], - note: str, + note: Union[str, None], image: Union[str, bytes, Image.Image, BytesIO, BufferedReader, np.ndarray, None] = None, + is_pinned: bool = False, ) -> None: """ Adds a note to a given detector. @@ -391,7 +392,7 @@ def create_note( # self.notes_api.create_note(det_id, note, **kwargs) url = f"{self.endpoint}/v1/notes" files = {"image": ("image.jpg", img_bytes, "image/jpeg")} if img_bytes is not None else None - data = {"content": note} + data = {"content": note, "is_pinned": is_pinned} params = {"detector_id": det_id} headers = {"x-api-token": self.configuration.api_key["ApiToken"]} diff --git a/test/unit/test_notes.py b/test/unit/test_notes.py index bf99e3cf..68bad7d9 100644 --- a/test/unit/test_notes.py +++ b/test/unit/test_notes.py @@ -26,3 +26,15 @@ def test_note_with_image(gl_experimental: ExperimentalApi): if notes[i].content == "test_note": found_note = True assert found_note + +def test_note_pinned(gl_experimental: ExperimentalApi): + name = f"Test {datetime.utcnow()}" + det = gl_experimental.create_detector(name, "test_query") + gl_experimental.create_note(det, "test_note", "test/assets/cat.jpeg", True) + notes = (gl_experimental.get_notes(det).get("customer") or []) + (gl_experimental.get_notes(det).get("gl") or []) + found_note = False + for i in range(len(notes)): + if notes[i].content == "test_note": + found_note = True + assert notes[i].is_pinned + assert found_note \ No newline at end of file From 8335c3b76bb3d6cb9de8ca75c3fa731164f00be6 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Wed, 8 Jan 2025 21:52:13 +0000 Subject: [PATCH 2/2] Automatically reformatting code --- test/unit/test_notes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/test_notes.py b/test/unit/test_notes.py index 68bad7d9..d1a9fb9d 100644 --- a/test/unit/test_notes.py +++ b/test/unit/test_notes.py @@ -27,6 +27,7 @@ def test_note_with_image(gl_experimental: ExperimentalApi): found_note = True assert found_note + def test_note_pinned(gl_experimental: ExperimentalApi): name = f"Test {datetime.utcnow()}" det = gl_experimental.create_detector(name, "test_query") @@ -37,4 +38,4 @@ def test_note_pinned(gl_experimental: ExperimentalApi): if notes[i].content == "test_note": found_note = True assert notes[i].is_pinned - assert found_note \ No newline at end of file + assert found_note