From 2b5061e2dc7cb06f73d545417a693e058b742495 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Thu, 20 Oct 2022 17:31:04 -0700 Subject: [PATCH 1/7] Polishing some sdk tests --- tests/integration/test_data_rows.py | 6 +++--- tests/integration/test_delegated_access.py | 4 ++-- tests/integration/test_label.py | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_data_rows.py b/tests/integration/test_data_rows.py index 563358058..7267a523c 100644 --- a/tests/integration/test_data_rows.py +++ b/tests/integration/test_data_rows.py @@ -150,14 +150,14 @@ def test_data_row_bulk_creation(dataset, rand_gen, image_url): @pytest.mark.slow def test_data_row_large_bulk_creation(dataset, image_url): # Do a longer task and expect it not to be complete immediately - n_local = 2000 - n_urls = 250 + n_urls = 1000 + n_local = 250 with NamedTemporaryFile() as fp: fp.write("Test data".encode()) fp.flush() task = dataset.create_data_rows([{ DataRow.row_data: image_url - }] * n_local + [fp.name] * n_urls) + }] * n_urls + [fp.name] * n_local) task.wait_till_done() assert task.status == "COMPLETE" assert len(list(dataset.data_rows())) == n_local + n_urls diff --git a/tests/integration/test_delegated_access.py b/tests/integration/test_delegated_access.py index 91b847627..2083c8d99 100644 --- a/tests/integration/test_delegated_access.py +++ b/tests/integration/test_delegated_access.py @@ -6,7 +6,7 @@ from labelbox import Client -@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") is None, +@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") == "", reason="DA_GCP_LABELBOX_API_KEY not found") def test_default_integration(): """ @@ -28,7 +28,7 @@ def test_default_integration(): ds.delete() -@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") is None, +@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") == "", reason="DA_GCP_LABELBOX_API_KEY not found") def test_non_default_integration(): """ diff --git a/tests/integration/test_label.py b/tests/integration/test_label.py index f8e473c0f..c6057cb4c 100644 --- a/tests/integration/test_label.py +++ b/tests/integration/test_label.py @@ -46,6 +46,7 @@ def test_label_export(configured_project_with_label): # TODO: Skipping this test in staging due to label not updating @pytest.mark.skipif(condition=os.environ['LABELBOX_TEST_ENVIRON'] == "onprem" or os.environ['LABELBOX_TEST_ENVIRON'] == "staging" or + os.environ['LABELBOX_TEST_ENVIRON'] == "local" or os.environ['LABELBOX_TEST_ENVIRON'] == "custom", reason="does not work for onprem") def test_label_update(configured_project_with_label): From da66ff5a9d4f054483c632143c078babcd97ee90 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 10:35:02 -0700 Subject: [PATCH 2/7] Fix DA access test condition --- tests/integration/test_delegated_access.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_delegated_access.py b/tests/integration/test_delegated_access.py index 2083c8d99..01a9702d7 100644 --- a/tests/integration/test_delegated_access.py +++ b/tests/integration/test_delegated_access.py @@ -6,7 +6,7 @@ from labelbox import Client -@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") == "", +@pytest.mark.skipif(not os.environ.get('DA_GCP_LABELBOX_API_KEY'), reason="DA_GCP_LABELBOX_API_KEY not found") def test_default_integration(): """ @@ -28,7 +28,7 @@ def test_default_integration(): ds.delete() -@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") == "", +@pytest.mark.skipif(not os.environ.get("DA_GCP_LABELBOX_API_KEY"), reason="DA_GCP_LABELBOX_API_KEY not found") def test_non_default_integration(): """ From bf624fd5195a40405133326ea8e60c9f323c5e2a Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 10:51:41 -0700 Subject: [PATCH 3/7] Add assertion for label creation state --- tests/integration/conftest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 8b01631aa..4778cd46d 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -15,6 +15,7 @@ from labelbox.orm import query from labelbox.pagination import PaginatedCollection from labelbox.schema.annotation_import import LabelImport +from labelbox.schema.enums import AnnotationImportState from labelbox.schema.invite import Invite from labelbox.schema.queue_mode import QueueMode from labelbox.schema.user import User @@ -334,6 +335,7 @@ def create_label(): upload_task = LabelImport.create_from_objects( client, project.uid, f'label-import-{uuid.uuid4()}', predictions) upload_task.wait_until_done(sleep_time_seconds=5) + assert(upload_task.state == AnnotationImportState.FAILED) project.create_label = create_label project.create_label() From 426789db8e2c7c23f2b4e406c2afeca8f0e34c0b Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 10:54:39 -0700 Subject: [PATCH 4/7] yapf --- tests/integration/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 4778cd46d..729d9c4fc 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -335,7 +335,7 @@ def create_label(): upload_task = LabelImport.create_from_objects( client, project.uid, f'label-import-{uuid.uuid4()}', predictions) upload_task.wait_until_done(sleep_time_seconds=5) - assert(upload_task.state == AnnotationImportState.FAILED) + assert (upload_task.state == AnnotationImportState.FAILED) project.create_label = create_label project.create_label() From 22bc92188b0f11200643c049f232e7a1d48790a5 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 11:01:10 -0700 Subject: [PATCH 5/7] Changing assertion state --- tests/integration/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 729d9c4fc..3171f5815 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -335,7 +335,7 @@ def create_label(): upload_task = LabelImport.create_from_objects( client, project.uid, f'label-import-{uuid.uuid4()}', predictions) upload_task.wait_until_done(sleep_time_seconds=5) - assert (upload_task.state == AnnotationImportState.FAILED) + assert (upload_task.state == AnnotationImportState.FINISHED) project.create_label = create_label project.create_label() From 3dfa96d50f1e4cecd2801e22ccb1c64f18a0ec25 Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 11:08:42 -0700 Subject: [PATCH 6/7] gs --- tests/integration/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 3171f5815..b16c9c35b 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -335,7 +335,8 @@ def create_label(): upload_task = LabelImport.create_from_objects( client, project.uid, f'label-import-{uuid.uuid4()}', predictions) upload_task.wait_until_done(sleep_time_seconds=5) - assert (upload_task.state == AnnotationImportState.FINISHED) + breakpoint + assert upload_task.state == AnnotationImportState.FINISHED project.create_label = create_label project.create_label() From 58ac47be4e81811db7495949caa36f6048eecf5a Mon Sep 17 00:00:00 2001 From: Kevin Kim Date: Mon, 24 Oct 2022 11:08:52 -0700 Subject: [PATCH 7/7] Remove parens --- tests/integration/conftest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index b16c9c35b..ed295e268 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -335,7 +335,6 @@ def create_label(): upload_task = LabelImport.create_from_objects( client, project.uid, f'label-import-{uuid.uuid4()}', predictions) upload_task.wait_until_done(sleep_time_seconds=5) - breakpoint assert upload_task.state == AnnotationImportState.FINISHED project.create_label = create_label