Skip to content

Commit e35ed7b

Browse files
authored
Set up test embeddings to be reusable (#1757)
1 parent ce38800 commit e35ed7b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

libs/labelbox/tests/conftest.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
from labelbox.schema.quality_mode import QualityMode
3636
from labelbox.schema.queue_mode import QueueMode
3737
from labelbox.schema.user import User
38+
from labelbox.exceptions import LabelboxError
39+
from contextlib import suppress
3840
from labelbox import Client
3941

4042
IMG_URL = "https://picsum.photos/200/300.jpg"
@@ -1063,12 +1065,20 @@ def configured_project_with_complex_ontology(client, initial_dataset, rand_gen,
10631065
project.delete()
10641066

10651067

1066-
@pytest.fixture
1067-
def embedding(client: Client):
1068+
@pytest.fixture(scope="session")
1069+
def embedding(client: Client, environ):
1070+
10681071
uuid_str = uuid.uuid4().hex
10691072
embedding = client.create_embedding(f"sdk-int-{uuid_str}", 8)
10701073
yield embedding
1071-
embedding.delete()
1074+
# Remove all embeddings on staging
1075+
if environ == Environ.STAGING:
1076+
embeddings = client.get_embeddings()
1077+
for embedding in embeddings:
1078+
with suppress(LabelboxError):
1079+
embedding.delete()
1080+
else:
1081+
embedding.delete()
10721082

10731083

10741084
@pytest.fixture

0 commit comments

Comments
 (0)