From 54bdb80cd93ff4791991801c40bd461acf9c736d Mon Sep 17 00:00:00 2001 From: brandon Date: Fri, 19 Jul 2024 14:04:26 -0700 Subject: [PATCH 1/2] Adds the experimentalapi client class to the docs --- Makefile | 2 +- generated/model.py | 44 ++++++++++++++++++++++++++++- sphinx_docs/models.rst | 9 ++++++ src/groundlight/experimental_api.py | 5 ++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 551d67d5..5cc4a261 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ generate: install-generator ## Generate the SDK from our public openapi spec -o ./generated \ --additional-properties=packageName=groundlight_openapi_client # strict-nullable makes nullable fields Optional in the generated Pydantic classes: https://github.com/koxudaxi/datamodel-code-generator/issues/327 - poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable + poetry run datamodel-codegen --input spec/public-api.yaml --output generated/model.py --strict-nullable --use-schema-description poetry run black . PYTEST=poetry run pytest -v diff --git a/generated/model.py b/generated/model.py index a7cd1148..237e66a8 100644 --- a/generated/model.py +++ b/generated/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: public-api.yaml -# timestamp: 2024-07-12T20:41:35+00:00 +# timestamp: 2024-07-19T21:02:15+00:00 from __future__ import annotations @@ -12,6 +12,11 @@ class ChannelEnum(Enum): + """ + * `EMAIL` - EMAIL + * `TEXT` - TEXT + """ + EMAIL = "EMAIL" TEXT = "TEXT" @@ -25,6 +30,11 @@ class ImageQueryTypeEnum(Enum): class ModeEnum(Enum): + """ + * `BINARY` - BINARY + * `COUNT` - COUNT + """ + BINARY = "BINARY" COUNT = "COUNT" @@ -44,6 +54,13 @@ class ResultTypeEnum(Enum): class SnoozeTimeUnitEnum(Enum): + """ + * `DAYS` - DAYS + * `HOURS` - HOURS + * `MINUTES` - MINUTES + * `SECONDS` - SECONDS + """ + DAYS = "DAYS" HOURS = "HOURS" MINUTES = "MINUTES" @@ -51,6 +68,14 @@ class SnoozeTimeUnitEnum(Enum): class VerbEnum(Enum): + """ + * `ANSWERED_CONSECUTIVELY` - ANSWERED_CONSECUTIVELY + * `ANSWERED_WITHIN_TIME` - ANSWERED_WITHIN_TIME + * `CHANGED_TO` - CHANGED_TO + * `NO_CHANGE` - NO_CHANGE + * `NO_QUERIES` - NO_QUERIES + """ + ANSWERED_CONSECUTIVELY = "ANSWERED_CONSECUTIVELY" ANSWERED_WITHIN_TIME = "ANSWERED_WITHIN_TIME" CHANGED_TO = "CHANGED_TO" @@ -81,6 +106,11 @@ class ActionRequest(BaseModel): class AllNotes(BaseModel): + """ + Serializes all notes for a given detector, grouped by type as listed in UserProfile.NoteCategoryChoices + The fields must match whats in USERPROFILE.NoteCategoryChoices + """ + CUSTOMER: List[Note] GL: List[Note] @@ -96,6 +126,10 @@ class ConditionRequest(BaseModel): class Detector(BaseModel): + """ + Spec for serializing a detector object in the public API. + """ + id: str = Field(..., description="A unique ID for this object.") type: DetectorTypeEnum = Field(..., description="The type of this object.") created_at: datetime = Field(..., description="When this detector was created.") @@ -117,6 +151,10 @@ class Detector(BaseModel): class DetectorCreationInputRequest(BaseModel): + """ + Helper serializer for validating POST /detectors input. + """ + name: constr(min_length=1, max_length=200) = Field(..., description="A short, descriptive name for the detector.") query: constr(min_length=1, max_length=300) = Field(..., description="A question about the image.") group_name: Optional[constr(min_length=1, max_length=100)] = Field( @@ -148,6 +186,10 @@ class DetectorCreationInputRequest(BaseModel): class ImageQuery(BaseModel): + """ + Spec for serializing a image-query object in the public API. + """ + metadata: Optional[Dict[str, Any]] = Field(..., description="Metadata about the image query.") id: str = Field(..., description="A unique ID for this object.") type: ImageQueryTypeEnum = Field(..., description="The type of this object.") diff --git a/sphinx_docs/models.rst b/sphinx_docs/models.rst index 7fe069ad..cedc0ce7 100644 --- a/sphinx_docs/models.rst +++ b/sphinx_docs/models.rst @@ -5,6 +5,9 @@ SDK Client :members: :special-members: __init__ +.. autoclass:: groundlight.ExperimentalApi + :members: + :special-members: __init__ API Response Objects ===================== @@ -19,4 +22,10 @@ API Response Objects :model-show-json: True .. autopydantic_model:: model.PaginatedImageQueryList + :model-show-json: True + +.. autopydantic_model:: model.Rule + :model-show-json: True + +.. autopydantic_model:: model.PaginatedRuleList :model-show-json: True \ No newline at end of file diff --git a/src/groundlight/experimental_api.py b/src/groundlight/experimental_api.py index 8b5c21ee..2fc88d8c 100644 --- a/src/groundlight/experimental_api.py +++ b/src/groundlight/experimental_api.py @@ -26,6 +26,11 @@ class ExperimentalApi(Groundlight): def __init__(self, endpoint: Union[str, None] = None, api_token: Union[str, None] = None): + """ + Constructs an experimental groundlight client. The experimental client inherits all the functionality of the + base groundlight client, but also includes additional functionality that is still in development. Additional + functionality is subject to change + """ super().__init__(endpoint=endpoint, api_token=api_token) self.actions_api = ActionsApi(self.api_client) self.images_api = ImageQueriesApi(self.api_client) From dac4fbb2c92c20a1d3f1f8fce2c85133b6ef9ef0 Mon Sep 17 00:00:00 2001 From: Brandon <132288221+brandon-groundlight@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:55:13 -0700 Subject: [PATCH 2/2] Update src/groundlight/experimental_api.py Co-authored-by: Sunil Kumar --- src/groundlight/experimental_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/groundlight/experimental_api.py b/src/groundlight/experimental_api.py index 2fc88d8c..28e133ea 100644 --- a/src/groundlight/experimental_api.py +++ b/src/groundlight/experimental_api.py @@ -28,8 +28,8 @@ class ExperimentalApi(Groundlight): def __init__(self, endpoint: Union[str, None] = None, api_token: Union[str, None] = None): """ Constructs an experimental groundlight client. The experimental client inherits all the functionality of the - base groundlight client, but also includes additional functionality that is still in development. Additional - functionality is subject to change + base groundlight client, but also includes additional functionality that is still in development. Experimental + functionality is subject to change. """ super().__init__(endpoint=endpoint, api_token=api_token) self.actions_api = ActionsApi(self.api_client)