Skip to content

Commit 7d9d959

Browse files
Grant EatonGrant Eaton
authored andcommitted
format
1 parent 16728d0 commit 7d9d959

File tree

5 files changed

+48
-37
lines changed

5 files changed

+48
-37
lines changed

test.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/integration/annotation_import/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from typing import Type
99
from labelbox.schema.labeling_frontend import LabelingFrontend
10-
from labelbox.schema.annotation_import import MALPredictionImport, AnnotationImportState
10+
from labelbox.schema.annotation_import import MALPredictionImport, AnnotationImportState
1111

1212

1313
@pytest.fixture
@@ -346,13 +346,14 @@ def model_run_annotation_groups(client, configured_project,
346346

347347

348348
class AnnotationImportTestHelpers:
349+
349350
@staticmethod
350351
def assert_file_content(url: str, predictions):
351352
response = requests.get(url)
352353
assert response.text == ndjson.dumps(predictions)
353354

354355
@staticmethod
355-
def check_running_state(req, name, url=None):
356+
def check_running_state(req, name, url=None):
356357
assert req.name == name
357358
if url is not None:
358359
assert req.input_file_url == url
@@ -364,4 +365,3 @@ def check_running_state(req, name, url=None):
364365
@pytest.fixture
365366
def annotation_import_test_helpers() -> Type[AnnotationImportTestHelpers]:
366367
return AnnotationImportTestHelpers()
367-

tests/integration/annotation_import/test_bulk_import_request.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_validate_file(client, configured_project):
3939
#Schema ids shouldn't match
4040

4141

42-
def test_create_from_objects(configured_project, predictions, annotation_import_test_helpers):
42+
def test_create_from_objects(configured_project, predictions,
43+
annotation_import_test_helpers):
4344
name = str(uuid.uuid4())
4445

4546
bulk_import_request = configured_project.upload_annotations(
@@ -50,7 +51,8 @@ def test_create_from_objects(configured_project, predictions, annotation_import_
5051
assert bulk_import_request.error_file_url is None
5152
assert bulk_import_request.status_file_url is None
5253
assert bulk_import_request.state == BulkImportRequestState.RUNNING
53-
annotation_import_test_helpers.assert_file_content(bulk_import_request.input_file_url, predictions)
54+
annotation_import_test_helpers.assert_file_content(
55+
bulk_import_request.input_file_url, predictions)
5456

5557

5658
def test_create_from_local_file(tmp_path, predictions, configured_project):
@@ -68,7 +70,8 @@ def test_create_from_local_file(tmp_path, predictions, configured_project):
6870
assert bulk_import_request.error_file_url is None
6971
assert bulk_import_request.status_file_url is None
7072
assert bulk_import_request.state == BulkImportRequestState.RUNNING
71-
annotation_import_test_helpers.assert_file_content(bulk_import_request.input_file_url, predictions)
73+
annotation_import_test_helpers.assert_file_content(
74+
bulk_import_request.input_file_url, predictions)
7275

7376

7477
def test_get(client, configured_project):

tests/integration/annotation_import/test_label_import.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,26 @@
1414
def test_create_from_url(client, project, annotation_import_test_helpers):
1515
name = str(uuid.uuid4())
1616
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
17-
label_import = LabelImport.create_from_url(client=client, project_id=project.uid, name=name, url=url)
18-
assert label_import.parent_id == project.uid
17+
label_import = LabelImport.create_from_url(client=client,
18+
project_id=project.uid,
19+
name=name,
20+
url=url)
21+
assert label_import.parent_id == project.uid
1922
annotation_import_test_helpers.check_running_state(label_import, name, url)
2023

2124

22-
def test_create_from_objects(client, project, object_predictions, annotation_import_test_helpers):
25+
def test_create_from_objects(client, project, object_predictions,
26+
annotation_import_test_helpers):
2327
name = str(uuid.uuid4())
2428

25-
label_import = LabelImport.create_from_objects(client=client, project_id=project.uid, name=name, labels=object_predictions)
26-
assert label_import.parent_id == project.uid
29+
label_import = LabelImport.create_from_objects(client=client,
30+
project_id=project.uid,
31+
name=name,
32+
labels=object_predictions)
33+
assert label_import.parent_id == project.uid
2734
annotation_import_test_helpers.check_running_state(label_import, name)
28-
annotation_import_test_helpers.assert_file_content(label_import.input_file_url, object_predictions)
35+
annotation_import_test_helpers.assert_file_content(
36+
label_import.input_file_url, object_predictions)
2937

3038

3139
# TODO: add me when we add this ability
@@ -48,7 +56,10 @@ def test_get(client, project, annotation_import_test_helpers):
4856
name = str(uuid.uuid4())
4957
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
5058

51-
label_import = LabelImport.create_from_url(client=client, project_id=project.uid, name=name, url=url)
59+
label_import = LabelImport.create_from_url(client=client,
60+
project_id=project.uid,
61+
name=name,
62+
url=url)
5263

5364
assert label_import.parent_id == project.uid
5465
annotation_import_test_helpers.check_running_state(label_import, name, url)
@@ -57,7 +68,10 @@ def test_get(client, project, annotation_import_test_helpers):
5768
@pytest.mark.slow
5869
def test_wait_till_done(client, project, predictions):
5970
name = str(uuid.uuid4())
60-
label_import = LabelImport.create_from_objects(client=client, project_id=project.uid, name=name, labels=predictions)
71+
label_import = LabelImport.create_from_objects(client=client,
72+
project_id=project.uid,
73+
name=name,
74+
labels=predictions)
6175

6276
assert len(label_import.inputs) == len(predictions)
6377
label_import.wait_until_done()
@@ -68,9 +82,7 @@ def test_wait_till_done(client, project, predictions):
6882
# # Check that the status files are being returned as expected
6983
# assert len(label_import.errors) == 0
7084
assert len(label_import.inputs) == len(predictions)
71-
input_uuids = [
72-
input_annot['uuid'] for input_annot in label_import.inputs
73-
]
85+
input_uuids = [input_annot['uuid'] for input_annot in label_import.inputs]
7486
inference_uuids = [pred['uuid'] for pred in predictions]
7587
assert set(input_uuids) == set(inference_uuids)
7688
assert len(label_import.statuses) == len(predictions)
@@ -80,4 +92,3 @@ def test_wait_till_done(client, project, predictions):
8092
input_annot['uuid'] for input_annot in label_import.statuses
8193
]
8294
assert set(input_uuids) == set(status_uuids)
83-

tests/integration/annotation_import/test_mea_prediction_import.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,33 @@
1010
"""
1111

1212

13-
def test_create_from_url(model_run_annotation_groups, annotation_import_test_helpers):
13+
def test_create_from_url(model_run_annotation_groups,
14+
annotation_import_test_helpers):
1415
name = str(uuid.uuid4())
1516
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
1617
annotation_import = model_run_annotation_groups.add_predictions(
1718
name=name, predictions=url)
1819
assert annotation_import.model_run_id == model_run_annotation_groups.uid
19-
annotation_import_test_helpers.check_running_state(annotation_import, name, url)
20+
annotation_import_test_helpers.check_running_state(annotation_import, name,
21+
url)
2022

2123

22-
def test_create_from_objects(model_run_annotation_groups, object_predictions, annotation_import_test_helpers):
24+
def test_create_from_objects(model_run_annotation_groups, object_predictions,
25+
annotation_import_test_helpers):
2326
name = str(uuid.uuid4())
2427

2528
annotation_import = model_run_annotation_groups.add_predictions(
2629
name=name, predictions=object_predictions)
2730

2831
assert annotation_import.model_run_id == model_run_annotation_groups.uid
2932
annotation_import_test_helpers.check_running_state(annotation_import, name)
30-
annotation_import_test_helpers.assert_file_content(annotation_import.input_file_url, object_predictions)
33+
annotation_import_test_helpers.assert_file_content(
34+
annotation_import.input_file_url, object_predictions)
3135

3236

3337
def test_create_from_local_file(tmp_path, model_run_annotation_groups,
34-
object_predictions, annotation_import_test_helpers):
38+
object_predictions,
39+
annotation_import_test_helpers):
3540
name = str(uuid.uuid4())
3641
file_name = f"{name}.ndjson"
3742
file_path = tmp_path / file_name
@@ -43,10 +48,12 @@ def test_create_from_local_file(tmp_path, model_run_annotation_groups,
4348

4449
assert annotation_import.model_run_id == model_run_annotation_groups.uid
4550
annotation_import_test_helpers.check_running_state(annotation_import, name)
46-
annotation_import_test_helpers.assert_file_content(annotation_import.input_file_url, object_predictions)
51+
annotation_import_test_helpers.assert_file_content(
52+
annotation_import.input_file_url, object_predictions)
4753

4854

49-
def test_get(client, model_run_annotation_groups, annotation_import_test_helpers):
55+
def test_get(client, model_run_annotation_groups,
56+
annotation_import_test_helpers):
5057
name = str(uuid.uuid4())
5158
url = "https://storage.googleapis.com/labelbox-public-bucket/predictions_test_v2.ndjson"
5259
model_run_annotation_groups.add_predictions(name=name, predictions=url)
@@ -55,7 +62,8 @@ def test_get(client, model_run_annotation_groups, annotation_import_test_helpers
5562
client, model_run_id=model_run_annotation_groups.uid, name=name)
5663

5764
assert annotation_import.model_run_id == model_run_annotation_groups.uid
58-
annotation_import_test_helpers.check_running_state(annotation_import, name, url)
65+
annotation_import_test_helpers.check_running_state(annotation_import, name,
66+
url)
5967

6068

6169
@pytest.mark.slow
@@ -82,4 +90,3 @@ def test_wait_till_done(model_run_predictions, model_run_annotation_groups):
8290
input_annot['uuid'] for input_annot in annotation_import.statuses
8391
]
8492
assert set(input_uuids) == set(status_uuids)
85-

0 commit comments

Comments
 (0)