Skip to content

Commit e356ee9

Browse files
author
Matt Sokoloff
committed
add type hints, fix typos
1 parent 978f983 commit e356ee9

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

labelbox/schema/project.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,10 @@ def set_labeling_parameter_overrides(self, data):
351351
Args:
352352
data (iterable): An iterable of tuples. Each tuple must contain
353353
(DataRow, priority<int>, number_of_labels<int>) for the new override.
354+
354355
Priority:
355356
* Data will be labeled in priority order.
356-
- Lower number priority is labeled first.
357+
- A lower number priority is labeled first.
357358
- Minimum priority is 1.
358359
* Priority is not the queue position.
359360
- The position is determined by the relative priority.
@@ -363,15 +364,13 @@ def set_labeling_parameter_overrides(self, data):
363364
* The priority only effects items in the queue.
364365
- Assigning a priority will not automatically add the item back into the queue.
365366
Number of labels:
366-
* The number times a data row should be labeled.
367-
* This will create duplicate data rows in a project (one for each number of labels).
368-
* Data rows will be sent to the queue (even if they have already been labeled).
369-
- New copies will only be assigned to members who have not labeled that same datarow before.
367+
* The number of times a data row should be labeled.
368+
- Creates duplicate data rows in a project (one for each number of labels).
369+
* New duplicated data rows will be added to the queue.
370370
- Already labeled duplicates will not be sent back to the queue.
371371
* The queue will never assign the same datarow to a single labeler more than once.
372372
- If the number of labels is greater than the number of labelers working on a project then
373373
the extra items will remain in the queue (this can be fixed by removing the override at any time).
374-
375374
* Setting this to 1 will result in the default behavior (no duplicates).
376375
Returns:
377376
bool, indicates if the operation was a success.

labelbox/schema/webhook.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import logging
22
from enum import Enum
3-
from typing import Iterable, List
3+
from typing import List, Optional, Union
44

55
from labelbox.orm import query
66
from labelbox.orm.db_object import DbObject, Updateable
77
from labelbox.orm.model import Entity, Field, Relationship
8+
from labelbox import Client, Project
89

910
logger = logging.getLogger(__name__)
1011

@@ -55,7 +56,8 @@ class WebhookTopic(Enum):
5556
project = Relationship.ToOne("Project")
5657

5758
@staticmethod
58-
def create(client, topics, url, secret, project):
59+
def create(client: Client, topics: List[WebhookTopic], url: str,
60+
secret: str, project: Project):
5961
""" Creates a Webhook.
6062
6163
Args:
@@ -92,7 +94,7 @@ def create(client, topics, url, secret, project):
9294
return Webhook(client, client.execute(query_str)["createWebhook"])
9395

9496
@staticmethod
95-
def validate_topics(topics: List["Webhook.WebhookTopic"]):
97+
def validate_topics(topics: List[WebhookTopic]):
9698
if not isinstance(topics, list):
9799
raise TypeError(
98100
f"Topics must be List[Webhook.WebhookTopic]. Found `{topics}`")
@@ -101,23 +103,29 @@ def validate_topics(topics: List["Webhook.WebhookTopic"]):
101103
Webhook.validate_value(topic, Webhook.WebhookTopic)
102104

103105
@staticmethod
104-
def validate_value(value, enum):
106+
def validate_value(value: str, enum: Union[WebhookStatus, WebhookTopic]):
105107
supported_values = [x.value for x in enum]
106108
if value not in supported_values:
107109
raise ValueError(
108110
f"Value `{value}` does not exist in supported values. Expected one of {supported_values}"
109111
)
110112

111113
def delete(self):
114+
"""
115+
Deletes the webhook
116+
"""
112117
self.update(status=self.WebhookStatus.INACTIVE)
113118

114-
def update(self, topics=None, url=None, status=None):
119+
def update(self,
120+
topics: Optional[List[WebhookTopic]] = None,
121+
url: Optional[str] = None,
122+
status: Optional[WebhookStatus] = None):
115123
""" Updates the Webhook.
116124
117125
Args:
118-
topics (List[str]): The new topics.
119-
url (str): The new URL value.
120-
status (str): The new status.
126+
topics (Optional[List[WebhookTopic]]): The new topics.
127+
url Optional[str): The new URL value.
128+
status (Optional[WebhookStatus]): The new status.
121129
122130
If values are set to None then there are no updates made to that field.
123131

0 commit comments

Comments
 (0)