Skip to content

Commit

Permalink
added review_reasons to the SDK for posting labels (#104)
Browse files Browse the repository at this point in the history
* added review_reasons to the SDK for posting labels

* Automatically reformatting code

* PR feedback from mike

* Automatically reformatting code

* bump toml

* another lint fix

* another lint fix

* bump version for this change

---------

Co-authored-by: Auto-format Bot <[email protected]>
  • Loading branch information
sunildkumar and Auto-format Bot authored Dec 6, 2023
1 parent f6f82d5 commit e2c94d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generated/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ class PaginatedImageQueryList(BaseModel):
count: Optional[int] = Field(None, example=123)
next: Optional[AnyUrl] = Field(None, example="http://api.example.org/accounts/?page=4")
previous: Optional[AnyUrl] = Field(None, example="http://api.example.org/accounts/?page=2")
results: Optional[List[ImageQuery]] = None
results: Optional[List[ImageQuery]] = None
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ packages = [
{include = "**/*.py", from = "src"},
]
readme = "README.md"
version = "0.13.0"
version = "0.13.1"

[tool.poetry.dependencies]
# For certifi, use ">=" instead of "^" since it upgrades its "major version" every year, not really following semver
Expand Down
12 changes: 8 additions & 4 deletions src/groundlight/internalapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import random
import time
import uuid
from enum import Enum
from functools import wraps
from typing import Callable, Dict, Optional, Union
from urllib.parse import urlsplit, urlunsplit
Expand Down Expand Up @@ -155,6 +156,12 @@ def decorated(*args, **kwargs): # pylint: disable=inconsistent-return-statement
return decorated


# ReviewReasons are reasons a label was created. A review reason is a required field when posting a human label
# to the API. The only review reason currently supported on the SDK is CUSTOMER_INITIATED.
class ReviewReason(str, Enum): # noqa: N801
CUSTOMER_INITIATED = "CUSTOMER_INITIATED"


class GroundlightApiClient(ApiClient):
"""Subclassing the OpenAPI-generated ApiClient to add a bit of custom functionality.
Not crazy about using polymorphism, but this is simpler than modifying the moustache
Expand Down Expand Up @@ -199,10 +206,7 @@ def _add_label(self, image_query_id: str, label: str) -> dict:
start_time = time.time()
url = f"{self.configuration.host}/labels"

data = {
"label": label,
"posicheck_id": image_query_id,
}
data = {"label": label, "posicheck_id": image_query_id, "review_reason": ReviewReason.CUSTOMER_INITIATED}

headers = self._headers()

Expand Down

0 comments on commit e2c94d9

Please sign in to comment.