@@ -160,6 +160,35 @@ def labels(self, datasets=None, order_by=None):
160
160
return PaginatedCollection (self .client , query_str , {id_param : self .uid },
161
161
["project" , "labels" ], Label )
162
162
163
+ def export_queued_data_rows (self , timeout_seconds = 120 ):
164
+ """ Returns all data rows that are currently enqueued for this project.
165
+
166
+ Args:
167
+ timeout_seconds (float): Max waiting time, in seconds.
168
+ Returns:
169
+ URL of the data file with this DataRow information. If the server didn't
170
+ generate during the `timeout_seconds` period, None is returned.
171
+ """
172
+ id_param = "projectId"
173
+ query_str = """mutation GetQueuedDataRowsExportUrlPyApi($%s: ID!)
174
+ {exportQueuedDataRows(data:{projectId: $%s }) {downloadUrl createdAt status} }
175
+ """ % (id_param , id_param )
176
+ sleep_time = 2
177
+ while True :
178
+ res = self .client .execute (query_str , {id_param : self .uid })
179
+ res = res ["exportQueuedDataRows" ]
180
+ if res ["status" ] == "COMPLETE" :
181
+ return res ["downloadUrl" ]
182
+
183
+ timeout_seconds -= sleep_time
184
+ if timeout_seconds <= 0 :
185
+ return None
186
+
187
+ logger .debug (
188
+ "Project '%s' queued data row export, waiting for server..." ,
189
+ self .uid )
190
+ time .sleep (sleep_time )
191
+
163
192
def export_labels (self , timeout_seconds = 60 ):
164
193
""" Calls the server-side Label exporting that generates a JSON
165
194
payload, and returns the URL to that payload.
@@ -193,13 +222,13 @@ def export_labels(self, timeout_seconds=60):
193
222
time .sleep (sleep_time )
194
223
195
224
def export_issues (self , status = None ):
196
- """ Calls the server-side Issues exporting that
225
+ """ Calls the server-side Issues exporting that
197
226
returns the URL to that payload.
198
227
199
228
Args:
200
229
status (string): valid values: Open, Resolved
201
230
Returns:
202
- URL of the data file with this Project's issues.
231
+ URL of the data file with this Project's issues.
203
232
"""
204
233
id_param = "projectId"
205
234
status_param = "status"
@@ -229,14 +258,14 @@ def export_issues(self, status=None):
229
258
def upsert_instructions (self , instructions_file : str ):
230
259
"""
231
260
* Uploads instructions to the UI. Running more than once will replace the instructions
232
-
261
+
233
262
Args:
234
263
instructions_file (str): Path to a local file.
235
264
* Must be either a pdf, text, or html file.
236
265
237
266
Raises:
238
267
ValueError:
239
- * project must be setup
268
+ * project must be setup
240
269
* instructions file must end with one of ".text", ".txt", ".pdf", ".html"
241
270
"""
242
271
@@ -267,18 +296,18 @@ def upsert_instructions(self, instructions_file: str):
267
296
268
297
self .client .execute (
269
298
"""mutation UpdateFrontendWithExistingOptionsPyApi (
270
- $frontendId: ID!,
271
- $optionsId: ID!,
272
- $name: String!,
273
- $description: String!,
299
+ $frontendId: ID!,
300
+ $optionsId: ID!,
301
+ $name: String!,
302
+ $description: String!,
274
303
$customizationOptions: String!
275
304
) {
276
305
updateLabelingFrontend(
277
- where: {id: $frontendId},
306
+ where: {id: $frontendId},
278
307
data: {name: $name, description: $description}
279
308
) {id}
280
309
updateLabelingFrontendOptions(
281
- where: {id: $optionsId},
310
+ where: {id: $optionsId},
282
311
data: {customizationOptions: $customizationOptions}
283
312
) {id}
284
313
}""" , {
@@ -390,10 +419,10 @@ def validate_labeling_parameter_overrides(self, data):
390
419
391
420
def set_labeling_parameter_overrides (self , data ):
392
421
""" Adds labeling parameter overrides to this project.
393
-
422
+
394
423
See information on priority here:
395
424
https://docs.labelbox.com/en/configure-editor/queue-system#reservation-system
396
-
425
+
397
426
>>> project.set_labeling_parameter_overrides([
398
427
>>> (data_row_1, 2, 3), (data_row_2, 1, 4)])
399
428
@@ -407,11 +436,11 @@ def set_labeling_parameter_overrides(self, data):
407
436
- Minimum priority is 1.
408
437
* Priority is not the queue position.
409
438
- The position is determined by the relative priority.
410
- - E.g. [(data_row_1, 5,1), (data_row_2, 2,1), (data_row_3, 10,1)]
439
+ - E.g. [(data_row_1, 5,1), (data_row_2, 2,1), (data_row_3, 10,1)]
411
440
will be assigned in the following order: [data_row_2, data_row_1, data_row_3]
412
441
* Datarows with parameter overrides will appear before datarows without overrides.
413
442
* The priority only effects items in the queue.
414
- - Assigning a priority will not automatically add the item back into the queue.
443
+ - Assigning a priority will not automatically add the item back into the queue.
415
444
Number of labels:
416
445
* The number of times a data row should be labeled.
417
446
- Creates duplicate data rows in a project (one for each number of labels).
@@ -458,7 +487,7 @@ def unset_labeling_parameter_overrides(self, data_rows):
458
487
def upsert_review_queue (self , quota_factor ):
459
488
""" Sets the the proportion of total assets in a project to review.
460
489
461
- More information can be found here:
490
+ More information can be found here:
462
491
https://docs.labelbox.com/en/quality-assurance/review-labels#configure-review-percentage
463
492
464
493
Args:
0 commit comments