Skip to content

Commit e2c94d9

Browse files
sunildkumarAuto-format Bot
andauthored
added review_reasons to the SDK for posting labels (#104)
* 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]>
1 parent f6f82d5 commit e2c94d9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

generated/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ class PaginatedImageQueryList(BaseModel):
8787
count: Optional[int] = Field(None, example=123)
8888
next: Optional[AnyUrl] = Field(None, example="http://api.example.org/accounts/?page=4")
8989
previous: Optional[AnyUrl] = Field(None, example="http://api.example.org/accounts/?page=2")
90-
results: Optional[List[ImageQuery]] = None
90+
results: Optional[List[ImageQuery]] = None

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages = [
99
{include = "**/*.py", from = "src"},
1010
]
1111
readme = "README.md"
12-
version = "0.13.0"
12+
version = "0.13.1"
1313

1414
[tool.poetry.dependencies]
1515
# For certifi, use ">=" instead of "^" since it upgrades its "major version" every year, not really following semver

src/groundlight/internalapi.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import random
55
import time
66
import uuid
7+
from enum import Enum
78
from functools import wraps
89
from typing import Callable, Dict, Optional, Union
910
from urllib.parse import urlsplit, urlunsplit
@@ -155,6 +156,12 @@ def decorated(*args, **kwargs): # pylint: disable=inconsistent-return-statement
155156
return decorated
156157

157158

159+
# ReviewReasons are reasons a label was created. A review reason is a required field when posting a human label
160+
# to the API. The only review reason currently supported on the SDK is CUSTOMER_INITIATED.
161+
class ReviewReason(str, Enum): # noqa: N801
162+
CUSTOMER_INITIATED = "CUSTOMER_INITIATED"
163+
164+
158165
class GroundlightApiClient(ApiClient):
159166
"""Subclassing the OpenAPI-generated ApiClient to add a bit of custom functionality.
160167
Not crazy about using polymorphism, but this is simpler than modifying the moustache
@@ -199,10 +206,7 @@ def _add_label(self, image_query_id: str, label: str) -> dict:
199206
start_time = time.time()
200207
url = f"{self.configuration.host}/labels"
201208

202-
data = {
203-
"label": label,
204-
"posicheck_id": image_query_id,
205-
}
209+
data = {"label": label, "posicheck_id": image_query_id, "review_reason": ReviewReason.CUSTOMER_INITIATED}
206210

207211
headers = self._headers()
208212

0 commit comments

Comments
 (0)