Skip to content

Commit 4dddb80

Browse files
Add Project.extend_reservations.
1 parent e01ac6e commit 4dddb80

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

labelbox/schema/project.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,25 @@ def upsert_review_queue(self, quota_factor):
241241
query_str, {project_param: self.uid, quota_param: quota_factor})
242242

243243

244+
def extend_reservations(self, queue_type):
245+
""" Extend all the current reservations for the current user on the given
246+
queue type.
247+
Args:
248+
queue_type (str): Either "LabelingQueue" or "ReviewQueue"
249+
Return:
250+
int, the number of reservations that were extended.
251+
"""
252+
if queue_type not in ("LabelingQueue", "ReviewQueue"):
253+
raise InvalidQueryError("Unsupported queue type: %s" % queue_type)
254+
255+
project_param = "projectId"
256+
query_str = """mutation ExtendReservationsPyApi($%s: ID!){
257+
extendReservations(projectId:$%s queueType:%s)}""" % (
258+
project_param, project_param, queue_type)
259+
res = self.client.execute(query_str, {project_param: self.uid})
260+
return res["data"]["extendReservations"]
261+
262+
244263
class LabelingParameterOverride(DbObject):
245264
priority = Field.Int("priority")
246265
number_of_labels = Field.Int("number_of_labels")

tests/integration/test_project.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import pytest
2+
13
from labelbox import Project
4+
from labelbox.exceptions import InvalidQueryError
25

36

47
def test_project(client, rand_gen):
@@ -56,3 +59,12 @@ def test_upsert_review_queue(client, rand_gen):
5659
project = client.create_project(name=rand_gen(str))
5760
project.upsert_review_queue(0.6)
5861
project.delete()
62+
63+
64+
def test_extend_reservations(client, rand_gen):
65+
project = client.create_project(name=rand_gen(str))
66+
assert project.extend_reservations("LabelingQueue") == 0
67+
assert project.extend_reservations("ReviewQueue") == 0
68+
with pytest.raises(InvalidQueryError):
69+
project.extend_reservations("InvalidQueueType")
70+
project.delete()

0 commit comments

Comments
 (0)