File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff 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+
244263class LabelingParameterOverride (DbObject ):
245264 priority = Field .Int ("priority" )
246265 number_of_labels = Field .Int ("number_of_labels" )
Original file line number Diff line number Diff line change 1+ import pytest
2+
13from labelbox import Project
4+ from labelbox .exceptions import InvalidQueryError
25
36
47def 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 ()
You can’t perform that action at this time.
0 commit comments