From 02625c6c9c0ff9759596c7793f0b38c8994f4a97 Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:59:08 -0500 Subject: [PATCH 1/4] set up embeddings to be reusable --- libs/labelbox/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index 272b1c9c4..d79f6f854 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -1063,7 +1063,7 @@ def configured_project_with_complex_ontology(client, initial_dataset, rand_gen, project.delete() -@pytest.fixture +@pytest.fixture(scope="module") def embedding(client: Client): uuid_str = uuid.uuid4().hex embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8) From 69a38172d02524e60d1e6d5163670b5a011b2dbf Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:22:29 -0500 Subject: [PATCH 2/4] set up embeddings to be reusable --- libs/labelbox/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index d79f6f854..77d619317 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -1063,7 +1063,7 @@ def configured_project_with_complex_ontology(client, initial_dataset, rand_gen, project.delete() -@pytest.fixture(scope="module") +@pytest.fixture(scope="session") def embedding(client: Client): uuid_str = uuid.uuid4().hex embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8) From e3fbb039c3c305ddd92e59ebd4f7579f7e45f50a Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:27:45 -0500 Subject: [PATCH 3/4] set up embeddings to be reusable --- libs/labelbox/tests/conftest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index 77d619317..ef518b0b2 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -35,6 +35,8 @@ from labelbox.schema.quality_mode import QualityMode from labelbox.schema.queue_mode import QueueMode from labelbox.schema.user import User +from labelbox.exceptions import LabelboxError +from contextlib import suppress from labelbox import Client IMG_URL = "https://picsum.photos/200/300.jpg" @@ -1064,7 +1066,15 @@ def configured_project_with_complex_ontology(client, initial_dataset, rand_gen, @pytest.fixture(scope="session") -def embedding(client: Client): +def embedding(client: Client, environ): + + # Remove all embeddings on staging + if environ == Environ.STAGING: + embeddings = client.get_embeddings() + for embedding in embeddings: + with suppress(LabelboxError): + embedding.delete() + uuid_str = uuid.uuid4().hex embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8) yield embedding From b1138a8631a559cf0a3b969ae83fb86f63cb4acf Mon Sep 17 00:00:00 2001 From: Gabefire <33893811+Gabefire@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:38:13 -0500 Subject: [PATCH 4/4] fixed --- libs/labelbox/tests/conftest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index ef518b0b2..db47cc071 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -1067,18 +1067,18 @@ def configured_project_with_complex_ontology(client, initial_dataset, rand_gen, @pytest.fixture(scope="session") def embedding(client: Client, environ): - + + uuid_str = uuid.uuid4().hex + embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8) + yield embedding # Remove all embeddings on staging if environ == Environ.STAGING: embeddings = client.get_embeddings() for embedding in embeddings: with suppress(LabelboxError): embedding.delete() - - uuid_str = uuid.uuid4().hex - embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8) - yield embedding - embedding.delete() + else: + embedding.delete() @pytest.fixture