Skip to content

Commit 59eda33

Browse files
authored
Delete Taxonomy (#210)
* New version * taxonomy deletion code * Add note about annotation and prediction deletions * nits
1 parent 81623ef commit 59eda33

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

nucleus/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ def create_dataset(
391391
"""
392392
warnings.warn(
393393
"The default create_dataset('dataset_name', ...) method without the is_scene parameter will be deprecated soon in favor of providing the is_scene parameter explicitly. "
394-
"Please make sure to create a dataset with either create_dataset('dataset_name', is_scene=True, ...) to upload "
395-
"DatasetItems or create_dataset('dataset_name', is_scene=False, ...) to upload "
394+
"Please make sure to create a dataset with either create_dataset('dataset_name', is_scene=False, ...) to upload "
395+
"DatasetItems or create_dataset('dataset_name', is_scene=True, ...) to upload "
396396
"LidarScenes.",
397397
DeprecationWarning,
398398
)

nucleus/dataset.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,26 @@ def add_taxonomy(
976976
requests_command=requests.post,
977977
)
978978

979+
def delete_taxonomy(
980+
self,
981+
taxonomy_name: str,
982+
):
983+
"""Deletes the given taxonomy.
984+
985+
All annotations and predictions associated with the taxonomy will be deleted as well.
986+
987+
Parameters:
988+
taxonomy_name: The name of the taxonomy.
989+
990+
Returns:
991+
Returns a response with dataset_id, taxonomy_name and status of the delete taxonomy operation.
992+
"""
993+
return self._client.make_request(
994+
{},
995+
f"dataset/{self.id}/taxonomy/{taxonomy_name}",
996+
requests.delete,
997+
)
998+
979999
def items_and_annotations(
9801000
self,
9811001
) -> List[Dict[str, Union[DatasetItem, Dict[str, List[Annotation]]]]]:

tests/test_taxonomy.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@pytest.fixture()
77
def dataset(CLIENT):
8-
ds = CLIENT.create_dataset(TEST_DATASET_NAME)
8+
ds = CLIENT.create_dataset(TEST_DATASET_NAME, is_scene=False)
99

1010
ds.add_taxonomy(
1111
"[Pytest] taxonomy",
@@ -62,3 +62,13 @@ def test_duplicate_taxonomy_update(dataset):
6262
assert response["dataset_id"] == dataset.id
6363
assert response["taxonomy_name"] == "[Pytest] taxonomy"
6464
assert response["status"] == "Taxonomy updated"
65+
66+
67+
def test_delete_taxonomy(dataset):
68+
response = dataset.delete_taxonomy(
69+
"[Pytest] taxonomy",
70+
)
71+
72+
assert response["dataset_id"] == dataset.id
73+
assert response["taxonomy_name"] == "[Pytest] taxonomy"
74+
assert response["status"] == "Taxonomy successfully deleted"

0 commit comments

Comments
 (0)