|
1 | 1 | import time |
2 | 2 | import os |
| 3 | +from typing import Tuple |
3 | 4 | import uuid |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 | import requests |
7 | 8 |
|
8 | 9 | from labelbox import Project, LabelingFrontend, Dataset |
9 | 10 | from labelbox.exceptions import InvalidQueryError |
| 11 | +from labelbox.schema.data_row import DataRow |
| 12 | +from labelbox.schema.label import Label |
10 | 13 | from labelbox.schema.media_type import MediaType |
11 | 14 | from labelbox.schema.queue_mode import QueueMode |
12 | 15 |
|
@@ -42,6 +45,43 @@ def test_project(client, rand_gen): |
42 | 45 | assert project not in projects |
43 | 46 |
|
44 | 47 |
|
| 48 | +def test_batch_project_export_v2( |
| 49 | + configured_batch_project_with_label: Tuple[Project, Dataset, DataRow, |
| 50 | + Label], |
| 51 | + export_v2_test_helpers, dataset: Dataset, image_url: str): |
| 52 | + project, dataset, *_ = configured_batch_project_with_label |
| 53 | + |
| 54 | + batch = list(project.batches())[0] |
| 55 | + filters = { |
| 56 | + "last_activity_at": ["2000-01-01 00:00:00", "2050-01-01 00:00:00"], |
| 57 | + "label_created_at": ["2000-01-01 00:00:00", "2050-01-01 00:00:00"], |
| 58 | + "batch_id": batch.uid, |
| 59 | + } |
| 60 | + params = { |
| 61 | + "include_performance_details": True, |
| 62 | + "include_labels": True, |
| 63 | + "media_type_override": MediaType.Image |
| 64 | + } |
| 65 | + task_name = "test_batch_export_v2" |
| 66 | + task = dataset.create_data_rows([ |
| 67 | + { |
| 68 | + "row_data": image_url, |
| 69 | + "external_id": "my-image" |
| 70 | + }, |
| 71 | + ] * 2) |
| 72 | + task.wait_till_done() |
| 73 | + data_rows = [dr.uid for dr in list(dataset.export_data_rows())] |
| 74 | + batch_one = f'batch one {uuid.uuid4()}' |
| 75 | + |
| 76 | + # This test creates two batches, only one batch should be exporter |
| 77 | + # Creatin second batch that will not be used in the export due to the filter: batch_id |
| 78 | + project.create_batch(batch_one, data_rows) |
| 79 | + |
| 80 | + task_results = export_v2_test_helpers.run_project_export_v2_task( |
| 81 | + project, task_name=task_name, filters=filters, params=params) |
| 82 | + assert (batch.size == len(task_results)) |
| 83 | + |
| 84 | + |
45 | 85 | def test_project_export_v2(client, export_v2_test_helpers, |
46 | 86 | configured_project_with_label, |
47 | 87 | wait_for_data_row_processing): |
|
0 commit comments