From 77e006ab663c0070b40d95853066b6978d4070b0 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:44:37 -0500 Subject: [PATCH 1/4] improved test where --- .../tests/integration/test_filtering.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libs/labelbox/tests/integration/test_filtering.py b/libs/labelbox/tests/integration/test_filtering.py index 082809935..63e438748 100644 --- a/libs/labelbox/tests/integration/test_filtering.py +++ b/libs/labelbox/tests/integration/test_filtering.py @@ -3,17 +3,29 @@ from labelbox import Project from labelbox.exceptions import InvalidQueryError from labelbox.schema.queue_mode import QueueMode +from labelbox import MediaType +import time @pytest.fixture def project_to_test_where(client, rand_gen): + num_retries = 5 + p_a_name = f"a-{rand_gen(str)}" p_b_name = f"b-{rand_gen(str)}" p_c_name = f"c-{rand_gen(str)}" - - p_a = client.create_project(name=p_a_name, queue_mode=QueueMode.Batch) - p_b = client.create_project(name=p_b_name, queue_mode=QueueMode.Batch) - p_c = client.create_project(name=p_c_name, queue_mode=QueueMode.Batch) + + p_a = client.create_project(name=p_a_name, media_type=MediaType.Image) + p_b = client.create_project(name=p_b_name, media_type=MediaType.Image) + p_c = client.create_project(name=p_c_name, media_type=MediaType.Image) + + while (num_retries > 0): + projects = client.get_projects() + if projects is None or len(list(projects)) != 3: + num_retries -= 1 + time.sleep(5) + else: + break yield p_a, p_b, p_c From 29de040f1d544844baeda61baea04466683cb67a Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:24:13 -0500 Subject: [PATCH 2/4] set up try except block --- libs/labelbox/tests/integration/test_filtering.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/labelbox/tests/integration/test_filtering.py b/libs/labelbox/tests/integration/test_filtering.py index 63e438748..aff326ca1 100644 --- a/libs/labelbox/tests/integration/test_filtering.py +++ b/libs/labelbox/tests/integration/test_filtering.py @@ -21,12 +21,16 @@ def project_to_test_where(client, rand_gen): while (num_retries > 0): projects = client.get_projects() - if projects is None or len(list(projects)) != 3: + try: + if len(list(projects)) >= 3: + break + except TypeError: num_retries -= 1 time.sleep(5) - else: - break + if num_retries == 0: + raise TimeoutError("Hit max number of retries getting projects") + yield p_a, p_b, p_c p_a.delete() From b14c0895c0e152c612b58b1d336b67087ce21acf Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:34:36 -0500 Subject: [PATCH 3/4] set up try except block --- libs/labelbox/tests/integration/test_filtering.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/labelbox/tests/integration/test_filtering.py b/libs/labelbox/tests/integration/test_filtering.py index aff326ca1..c9ce1a0ff 100644 --- a/libs/labelbox/tests/integration/test_filtering.py +++ b/libs/labelbox/tests/integration/test_filtering.py @@ -2,7 +2,6 @@ from labelbox import Project from labelbox.exceptions import InvalidQueryError -from labelbox.schema.queue_mode import QueueMode from labelbox import MediaType import time @@ -24,6 +23,8 @@ def project_to_test_where(client, rand_gen): try: if len(list(projects)) >= 3: break + else: + raise TypeError() except TypeError: num_retries -= 1 time.sleep(5) From 96d6c4e92d4d8522218f199af981f30a850eb878 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:51:36 -0500 Subject: [PATCH 4/4] set up try except block --- libs/labelbox/tests/integration/test_filtering.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/labelbox/tests/integration/test_filtering.py b/libs/labelbox/tests/integration/test_filtering.py index c9ce1a0ff..3f2971094 100644 --- a/libs/labelbox/tests/integration/test_filtering.py +++ b/libs/labelbox/tests/integration/test_filtering.py @@ -4,6 +4,7 @@ from labelbox.exceptions import InvalidQueryError from labelbox import MediaType import time +import logging @pytest.fixture @@ -21,11 +22,12 @@ def project_to_test_where(client, rand_gen): while (num_retries > 0): projects = client.get_projects() try: + logging.log(level=2, msg=f"{len(list(projects))}") if len(list(projects)) >= 3: break else: raise TypeError() - except TypeError: + except: num_retries -= 1 time.sleep(5)