Skip to content

Commit 7506bd0

Browse files
committed
Move test, rename params
1 parent 34db8af commit 7506bd0

File tree

3 files changed

+56
-57
lines changed

3 files changed

+56
-57
lines changed

labelbox/schema/project.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ def label_generator(self, timeout_seconds=600, **kwargs):
287287
return LBV1Converter.deserialize_video(json_data, self.client)
288288
return LBV1Converter.deserialize(json_data)
289289

290-
def export_labels(
291-
self,
292-
download=False,
293-
timeout_seconds=1800,
294-
**kwargs) -> Optional[Union[str, List[Dict[Any, Any]]]]:
290+
def export_labels(self,
291+
download=False,
292+
timeout_seconds=1800,
293+
**kwargs) -> Optional[Union[str, List[Dict[Any, Any]]]]:
295294
""" Calls the server-side Label exporting that generates a JSON
296295
payload, and returns the URL to that payload.
297296
@@ -384,7 +383,7 @@ def _validate_datetime(string_date: str) -> bool:
384383
"""
385384

386385
def export_v2(self, task_name: str,
387-
params: Optional[ProjectExportParams]) -> Task:
386+
params: Optional[ProjectExportParams]) -> Task:
388387
_params = params or {}
389388
mutation_name = "exportDataRowsInProject"
390389
create_task_query_str = """mutation exportDataRowsInProjectPyApi($input: ExportDataRowsInProjectInput!){
@@ -398,19 +397,19 @@ def export_v2(self, task_name: str,
398397
},
399398
"params": {
400399
"includeAttachments":
401-
_params.get('include_attachments', False),
400+
_params.get('attachments', False),
402401
"includeMediaAttributes":
403-
_params.get('include_media_attributes', False),
402+
_params.get('media_attributes', False),
404403
"includeMetadata":
405-
_params.get('include_metadata_fields', False),
404+
_params.get('metadata_fields', False),
406405
"includeDataRowDetails":
407-
_params.get('include_data_row_details', False),
406+
_params.get('data_row_details', False),
408407
"includeProjectDetails":
409-
_params.get('include_project_details', False),
408+
_params.get('project_details', False),
410409
"includeLabels":
411-
_params.get('include_labels', False),
410+
_params.get('labels', False),
412411
"includePerformanceDetails":
413-
_params.get('include_performance_details', False),
412+
_params.get('performance_details', False),
414413
},
415414
}
416415
}

tests/integration/test_label.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import time
32

43
import pytest
@@ -44,49 +43,6 @@ def test_label_export(configured_project_with_label):
4443
# The new exporter doesn't work with the create_label mutation
4544

4645

47-
def test_export_v2(configured_project_with_label):
48-
project, _, _, label = configured_project_with_label
49-
label_id = label.uid
50-
# Wait for exporter to retrieve latest labels
51-
time.sleep(10)
52-
task_name = "test_label_export_v2"
53-
54-
# TODO: Right now we don't have a way to test this
55-
include_performance_details = True
56-
task = project.export_v2(
57-
task_name,
58-
params={
59-
"include_performance_details": include_performance_details,
60-
"include_labels": True
61-
})
62-
assert task.name == task_name
63-
task.wait_till_done()
64-
assert task.status == "COMPLETE"
65-
66-
def download_result(result_url):
67-
response = requests.get(result_url)
68-
response.raise_for_status()
69-
data = [json.loads(line) for line in response.text.splitlines()]
70-
return data
71-
72-
task_results = download_result(task.result_url)
73-
74-
for task_result in task_results:
75-
assert len(task_result['errors']) == 0
76-
task_project = task_result['projects'][project.uid]
77-
task_project_label_ids_set = set(
78-
map(lambda prediction: prediction['id'], task_project['labels']))
79-
assert label_id in task_project_label_ids_set
80-
81-
# TODO: Add back in when we have a way to test this
82-
# if include_performance_details:
83-
# assert 'include_performance_details' in task_result and task_result[
84-
# 'include_performance_details'] is not None
85-
# else:
86-
# assert 'include_performance_details' not in task_result or task_result[
87-
# 'include_performance_details'] is None
88-
89-
9046
# TODO: Skipping this test in staging due to label not updating
9147
@pytest.mark.skipif(condition=os.environ['LABELBOX_TEST_ENVIRON'] == "onprem" or
9248
os.environ['LABELBOX_TEST_ENVIRON'] == "staging" or

tests/integration/test_project.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import time
23
import os
34

@@ -41,6 +42,49 @@ def test_project(client, rand_gen):
4142
assert project not in projects
4243

4344

45+
def test_project_export_v2(configured_project_with_label):
46+
project, _, _, label = configured_project_with_label
47+
label_id = label.uid
48+
# Wait for exporter to retrieve latest labels
49+
time.sleep(10)
50+
task_name = "test_label_export_v2"
51+
52+
# TODO: Right now we don't have a way to test this
53+
include_performance_details = True
54+
task = project.export_v2(
55+
task_name,
56+
params={
57+
"include_performance_details": include_performance_details,
58+
"include_labels": True
59+
})
60+
assert task.name == task_name
61+
task.wait_till_done()
62+
assert task.status == "COMPLETE"
63+
64+
def download_result(result_url):
65+
response = requests.get(result_url)
66+
response.raise_for_status()
67+
data = [json.loads(line) for line in response.text.splitlines()]
68+
return data
69+
70+
task_results = download_result(task.result_url)
71+
72+
for task_result in task_results:
73+
assert len(task_result['errors']) == 0
74+
task_project = task_result['projects'][project.uid]
75+
task_project_label_ids_set = set(
76+
map(lambda prediction: prediction['id'], task_project['labels']))
77+
assert label_id in task_project_label_ids_set
78+
79+
# TODO: Add back in when we have a way to test this
80+
# if include_performance_details:
81+
# assert 'include_performance_details' in task_result and task_result[
82+
# 'include_performance_details'] is not None
83+
# else:
84+
# assert 'include_performance_details' not in task_result or task_result[
85+
# 'include_performance_details'] is None
86+
87+
4488
def test_update_project_resource_tags(client, rand_gen):
4589

4690
def delete_tag(tag_id: str):

0 commit comments

Comments
 (0)