Skip to content

Commit dfd6f3a

Browse files
author
Matt Sokoloff
committed
thread safe
1 parent c1029a4 commit dfd6f3a

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

labelbox/orm/db_object.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,11 @@ def delete(self):
259259
def beta(fn):
260260

261261
def wrapper(self, *args, **kwargs):
262-
if not isinstance(self, DbObject):
263-
raise TypeError(
264-
"Cannot decorate functions that are not functions of `DbOjects` with `beta` decorator"
265-
)
266262
if not self.client.enable_beta:
267263
raise Exception(
268264
f"This function {fn.__name__} relies on a beta feature in the api. This means that the interface could change."
269265
" Set `enable_beta=True` in the client to enable use of these functions."
270266
)
271-
execute_fn = self.client.execute
272-
try:
273-
self.client.execute = partial(execute_fn, beta=True)
274-
result = fn(self, *args, **kwargs)
275-
if isinstance(result, PaginatedCollection):
276-
result.beta = True
277-
return result
278-
finally:
279-
self.client.execute = execute_fn
267+
return fn(self, *args, **kwargs)
280268

281269
return wrapper

labelbox/pagination.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def __init__(self,
1717
params,
1818
dereferencing,
1919
obj_class,
20-
cursor_path=None):
20+
cursor_path=None,
21+
beta=False):
2122
""" Creates a PaginatedCollection.
2223
2324
Args:
@@ -39,7 +40,7 @@ def __init__(self,
3940
self.params = params
4041
self.dereferencing = dereferencing
4142
self.obj_class = obj_class
42-
self.beta = False
43+
self.beta = beta
4344

4445
self._fetched_all = False
4546
self._data = []

labelbox/schema/organization.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,16 @@ def invite_user(
103103
"projectRoleId": project_role.role.uid
104104
} for project_role in _project_roles]
105105

106-
res = self.client.execute(
107-
query_str,
108-
{
109-
data_param: [{
110-
"inviterId": self.client.get_user().uid,
111-
"inviteeEmail": email,
112-
"organizationId": self.uid,
113-
"organizationRoleId": role.uid,
114-
"projects": projects
115-
}]
116-
},
117-
)
118-
# We prob want to return an invite
119-
# Could support bulk ops in the future
106+
res = self.client.execute(query_str, {
107+
data_param: [{
108+
"inviterId": self.client.get_user().uid,
109+
"inviteeEmail": email,
110+
"organizationId": self.uid,
111+
"organizationRoleId": role.uid,
112+
"projects": projects
113+
}]
114+
},
115+
beta=True)
120116
invite_response = res['createInvites'][0]['invite']
121117
return Invite(self.client, invite_response)
122118

@@ -131,10 +127,10 @@ def invite_limit(self) -> InviteLimit:
131127
132128
"""
133129
org_id_param = "organizationId"
134-
res = self.client.execute(
135-
"""query InvitesLimitPyApi($%s: ID!) {
130+
res = self.client.execute("""query InvitesLimitPyApi($%s: ID!) {
136131
invitesLimit(where: {id: $%s}) { used limit remaining }
137-
}""" % (org_id_param, org_id_param), {org_id_param: self.uid})
132+
}""" % (org_id_param, org_id_param), {org_id_param: self.uid},
133+
beta=True)
138134
return InviteLimit(
139135
**{utils.snake_case(k): v for k, v in res['invitesLimit'].items()})
140136

0 commit comments

Comments
 (0)