Skip to content

Commit 18b6cf1

Browse files
author
Val Brodsky
committed
Initial fix to delete feature schema resources
1 parent d7f6fe3 commit 18b6cf1

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

libs/labelbox/tests/conftest.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def configured_project_with_label(
666666
)
667667
yield [project, dataset, data_row, label]
668668

669+
client.delete_unused_ontology(ontology.uid)
669670
for label in project.labels():
670671
label.delete()
671672

@@ -735,14 +736,16 @@ def big_dataset(dataset: Dataset):
735736

736737

737738
@pytest.fixture
738-
def configured_batch_project_with_label(
739-
project, dataset, data_row, wait_for_label_processing
740-
):
739+
def configured_batch_project_with_label(client, dataset, data_row,
740+
wait_for_label_processing):
741741
"""Project with a batch having one datarow
742742
Project contains an ontology with 1 bbox tool
743743
Additionally includes a create_label method for any needed extra labels
744744
One label is already created and yielded when using fixture
745745
"""
746+
project = client.create_project(name=rand_gen(str),
747+
queue_mode=QueueMode.Batch,
748+
media_type=MediaType.Image)
746749
data_rows = [dr.uid for dr in list(dataset.data_rows())]
747750
project._wait_until_data_rows_are_processed(
748751
data_row_ids=data_rows, sleep_interval=3
@@ -757,18 +760,22 @@ def configured_batch_project_with_label(
757760

758761
yield [project, dataset, data_row, label]
759762

763+
project.client.delete_unused_ontology(ontology.uid)
760764
for label in project.labels():
761765
label.delete()
762766

763767

764768
@pytest.fixture
765-
def configured_batch_project_with_multiple_datarows(
766-
project, dataset, data_rows, wait_for_label_processing
767-
):
769+
def configured_batch_project_with_multiple_datarows(client, dataset, data_rows,
770+
wait_for_label_processing,
771+
rand_gen):
768772
"""Project with a batch having multiple datarows
769773
Project contains an ontology with 1 bbox tool
770774
Additionally includes a create_label method for any needed extra labels
771775
"""
776+
project = client.create_project(name=rand_gen(str),
777+
queue_mode=QueueMode.Batch,
778+
media_type=MediaType.Image)
772779
global_keys = [dr.global_key for dr in data_rows]
773780

774781
batch_name = f"batch {uuid.uuid4()}"
@@ -780,9 +787,19 @@ def configured_batch_project_with_multiple_datarows(
780787

781788
yield [project, dataset, data_rows]
782789

790+
featureSchemaIds = [tool.feature_schema_id for tool in ontology.tools]
791+
ontology = project.ontology()
792+
ontology_id = ontology.uid
793+
client = project.client
794+
783795
for label in project.labels():
784796
label.delete()
785797

798+
project.delete()
799+
client.delete_unused_ontology(ontology_id)
800+
for featureSchemaId in featureSchemaIds:
801+
project.client.delete_unused_feature_schema(featureSchemaId)
802+
786803

787804
@pytest.fixture
788805
def configured_batch_project_for_labeling_service(

libs/labelbox/tests/integration/test_feature_schema.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,24 @@ def test_throws_an_error_if_feature_schema_to_delete_doesnt_exist(client):
5858
client.delete_unused_feature_schema("doesntexist")
5959

6060

61-
def test_updates_a_feature_schema_title(client):
62-
tool = client.upsert_feature_schema(point.asdict())
63-
feature_schema_id = tool.normalized["featureSchemaId"]
61+
def test_updates_a_feature_schema_title(client, feature_schema):
62+
feature_schema_id = feature_schema.normalized['featureSchemaId']
6463
new_title = "new title"
6564
updated_feature_schema = client.update_feature_schema_title(
6665
feature_schema_id, new_title
6766
)
6867

6968
assert updated_feature_schema.normalized["name"] == new_title
7069

71-
client.delete_unused_feature_schema(feature_schema_id)
72-
7370

7471
def test_throws_an_error_when_updating_a_feature_schema_with_empty_title(
75-
client,
76-
):
77-
tool = client.upsert_feature_schema(point.asdict())
78-
feature_schema_id = tool.normalized["featureSchemaId"]
72+
client, feature_schema):
73+
tool = feature_schema
74+
feature_schema_id = tool.normalized['featureSchemaId']
7975

8076
with pytest.raises(Exception):
8177
client.update_feature_schema_title(feature_schema_id, "")
8278

83-
client.delete_unused_feature_schema(feature_schema_id)
84-
8579

8680
def test_throws_an_error_when_updating_not_existing_feature_schema(client):
8781
with pytest.raises(Exception):
@@ -107,15 +101,9 @@ def test_updates_a_feature_schema(client, feature_schema):
107101
assert updated_feature_schema.normalized["name"] == "new name"
108102

109103

110-
<<<<<<< HEAD
111-
def test_does_not_include_used_feature_schema(client):
112-
tool = client.upsert_feature_schema(point.asdict())
113-
feature_schema_id = tool.normalized["featureSchemaId"]
114-
=======
115104
def test_does_not_include_used_feature_schema(client, feature_schema):
116105
tool = feature_schema
117106
feature_schema_id = tool.normalized['featureSchemaId']
118-
>>>>>>> b54a37e7 (Followup update for the feature schema test)
119107
ontology = client.create_ontology_from_feature_schemas(
120108
name="ontology name",
121109
feature_schema_ids=[feature_schema_id],

0 commit comments

Comments
 (0)