Skip to content

Commit

Permalink
Delete Taxonomy (#210)
Browse files Browse the repository at this point in the history
* New version

* taxonomy deletion code

* Add note about annotation and prediction deletions

* nits
  • Loading branch information
cmpajot authored Feb 7, 2022
1 parent 81623ef commit 59eda33
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nucleus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def create_dataset(
"""
warnings.warn(
"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. "
"Please make sure to create a dataset with either create_dataset('dataset_name', is_scene=True, ...) to upload "
"DatasetItems or create_dataset('dataset_name', is_scene=False, ...) to upload "
"Please make sure to create a dataset with either create_dataset('dataset_name', is_scene=False, ...) to upload "
"DatasetItems or create_dataset('dataset_name', is_scene=True, ...) to upload "
"LidarScenes.",
DeprecationWarning,
)
Expand Down
20 changes: 20 additions & 0 deletions nucleus/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,26 @@ def add_taxonomy(
requests_command=requests.post,
)

def delete_taxonomy(
self,
taxonomy_name: str,
):
"""Deletes the given taxonomy.
All annotations and predictions associated with the taxonomy will be deleted as well.
Parameters:
taxonomy_name: The name of the taxonomy.
Returns:
Returns a response with dataset_id, taxonomy_name and status of the delete taxonomy operation.
"""
return self._client.make_request(
{},
f"dataset/{self.id}/taxonomy/{taxonomy_name}",
requests.delete,
)

def items_and_annotations(
self,
) -> List[Dict[str, Union[DatasetItem, Dict[str, List[Annotation]]]]]:
Expand Down
12 changes: 11 additions & 1 deletion tests/test_taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@pytest.fixture()
def dataset(CLIENT):
ds = CLIENT.create_dataset(TEST_DATASET_NAME)
ds = CLIENT.create_dataset(TEST_DATASET_NAME, is_scene=False)

ds.add_taxonomy(
"[Pytest] taxonomy",
Expand Down Expand Up @@ -62,3 +62,13 @@ def test_duplicate_taxonomy_update(dataset):
assert response["dataset_id"] == dataset.id
assert response["taxonomy_name"] == "[Pytest] taxonomy"
assert response["status"] == "Taxonomy updated"


def test_delete_taxonomy(dataset):
response = dataset.delete_taxonomy(
"[Pytest] taxonomy",
)

assert response["dataset_id"] == dataset.id
assert response["taxonomy_name"] == "[Pytest] taxonomy"
assert response["status"] == "Taxonomy successfully deleted"

0 comments on commit 59eda33

Please sign in to comment.