@@ -68,14 +68,15 @@ def remove_queued_data_rows(self) -> None:
6868
6969 project_id_param = "projectId"
7070 batch_id_param = "batchId"
71- self .client .execute ("""mutation ArchiveBatchPyApi($%s: ID!, $%s: ID!) {
72- project(where: {id: $%s}) { archiveBatch(batchId: $%s) { id archivedAt } }
71+ self .client .execute (
72+ """mutation RemoveQueuedDataRowsFromBatchPyApi($%s: ID!, $%s: ID!) {
73+ project(where: {id: $%s}) { removeQueuedDataRowsFromBatch(batchId: $%s) { id } }
7374 }""" % (project_id_param , batch_id_param , project_id_param ,
7475 batch_id_param ), {
7576 project_id_param : self .project_id ,
7677 batch_id_param : self .uid
7778 },
78- experimental = True )
79+ experimental = True )
7980
8081 def export_data_rows (self ,
8182 timeout_seconds = 120 ,
@@ -125,3 +126,50 @@ def export_data_rows(self,
125126 logger .debug ("Batch '%s' data row export, waiting for server..." ,
126127 self .uid )
127128 time .sleep (sleep_time )
129+
130+ def delete (self ) -> None :
131+ """ Deletes the given batch.
132+
133+ Note: Batch deletion for batches that has labels is forbidden.
134+
135+ Args:
136+ batch (Batch): Batch to remove queued data rows from
137+ """
138+
139+ project_id_param = "projectId"
140+ batch_id_param = "batchId"
141+ self .client .execute ("""mutation DeleteBatchPyApi($%s: ID!, $%s: ID!) {
142+ project(where: {id: $%s}) { deleteBatch(batchId: $%s) { deletedBatchId } }
143+ }""" % (project_id_param , batch_id_param , project_id_param ,
144+ batch_id_param ), {
145+ project_id_param : self .project_id ,
146+ batch_id_param : self .uid
147+ },
148+ experimental = True )
149+
150+ def delete_labels (self , set_labels_as_template = False ) -> None :
151+ """ Deletes labels that were created for data rows in the batch.
152+
153+ Args:
154+ batch (Batch): Batch to remove queued data rows from
155+ set_labels_as_template (bool): When set to true, the deleted labels will be kept as templates.
156+ """
157+
158+ project_id_param = "projectId"
159+ batch_id_param = "batchId"
160+ type_param = "type"
161+ res = self .client .execute (
162+ """mutation DeleteBatchLabelsPyApi($%s: ID!, $%s: ID!, $%s: DeleteBatchLabelsType!) {
163+ project(where: {id: $%s}) { deleteBatchLabels(batchId: $%s, data:{ type: $%s }) { deletedLabelIds } }
164+ }""" % (project_id_param , batch_id_param , type_param , project_id_param ,
165+ batch_id_param , type_param ), {
166+ project_id_param :
167+ self .project_id ,
168+ batch_id_param :
169+ self .uid ,
170+ type_param :
171+ "RequeueDataWithLabelAsTemplate"
172+ if set_labels_as_template else "RequeueData"
173+ },
174+ experimental = True )
175+ return res
0 commit comments