Skip to content

Commit 5a2ac10

Browse files
author
Val Brodsky
committed
Added docstring and readthedocs page
1 parent b0ed92d commit 5a2ac10

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

docs/labelbox/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ Labelbox Python SDK Documentation
5252
task
5353
task-queue
5454
user
55+
user-group-upload
5556
webhook

libs/labelbox/src/labelbox/schema/user_group_upload.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,66 @@
1616

1717
@dataclass
1818
class UploadReportLine:
19+
"""A single line in the CSV report of the upload members mutation.
20+
Both errors and successes are reported here.
21+
22+
Example output when using dataclasses.asdict():
23+
>>> {
24+
>>> 'lines': [
25+
>>> {
26+
>>> 'email': '...',
27+
>>> 'result': 'Not added',
28+
>>> 'error': 'User not found in the current organization'
29+
>>> },
30+
>>> {
31+
>>> 'email': '...',
32+
>>> 'result': 'Not added',
33+
>>> 'error': 'Member already exists in group'
34+
>>> },
35+
>>> {
36+
>>> 'email': '...',
37+
>>> 'result': 'Added',
38+
>>> 'error': ''
39+
>>> }
40+
>>> ]
41+
>>> }
42+
"""
1943
email: str
2044
result: str
2145
error: Optional[str] = None
2246

2347

2448
@dataclass
2549
class UploadReport:
50+
"""The report of the upload members mutation."""
2651
lines: List[UploadReportLine]
2752

2853

2954
class UserGroupUpload:
55+
"""Upload members to a user group."""
56+
3057
def __init__(self, client: Client):
3158
self.client = client
3259

3360
def upload_members(
3461
self, group_id: str, role: str, emails: List[str]
3562
) -> Optional[UploadReport]:
63+
"""Upload members to a user group.
64+
65+
Args:
66+
group_id: A valid ID of the user group.
67+
role: The name of the role to assign to the uploaded members as it appears in the UI on the Import Members popup.
68+
emails: The list of emails of the members to upload.
69+
70+
Returns:
71+
UploadReport: The report of the upload members mutation.
72+
73+
Raises:
74+
ResourceNotFoundError: If the role is not found.
75+
LabelboxError: If the upload fails.
76+
77+
For indicvidual email errors, the error message is available in the UploadReport.
78+
"""
3679
if len(emails) == 0:
3780
print("No emails to upload.")
3881
return None

0 commit comments

Comments
 (0)