Skip to content

Commit e103fbd

Browse files
Default delete_annotation ref_ids to an empty list (#328)
* Default delete_annotation ref_ids to list * Default keep_history to true * Appended changelog and bumped version
1 parent 3e96c6f commit e103fbd

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.14.6](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.6) - 2022-07-07
9+
10+
### Fixed
11+
- `Dataset.delete_annotations` now defaults `reference_ids` to an empty list and `keep_history` to true
12+
813
## [0.14.5](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.5) - 2022-07-05
914

1015
### Fixed

nucleus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def delete_slice(self, slice_id: str) -> dict:
852852

853853
@deprecated("Prefer calling Dataset.delete_annotations instead.")
854854
def delete_annotations(
855-
self, dataset_id: str, reference_ids: list = None, keep_history=False
855+
self, dataset_id: str, reference_ids: list = None, keep_history=True
856856
) -> AsyncJob:
857857
dataset = self.get_dataset(dataset_id)
858858
return dataset.delete_annotations(reference_ids, keep_history)

nucleus/dataset.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,24 +1213,27 @@ def export_embeddings(
12131213
return api_payload # type: ignore
12141214

12151215
def delete_annotations(
1216-
self, reference_ids: list = None, keep_history=False
1216+
self, reference_ids: list = None, keep_history=True
12171217
) -> AsyncJob:
12181218
"""Deletes all annotations associated with the specified item reference IDs.
12191219
12201220
Parameters:
12211221
reference_ids: List of user-defined reference IDs of the dataset items
1222-
from which to delete annotations.
1222+
from which to delete annotations. Defaults to an empty list.
12231223
keep_history: Whether to preserve version history. If False, all
12241224
previous versions will be deleted along with the annotations. If
12251225
True, the version history (including deletion) wil persist.
1226-
Default is False.
1226+
Default is True.
12271227
12281228
Returns:
12291229
:class:`AsyncJob`: Empty payload response.
12301230
"""
1231-
payload = {KEEP_HISTORY_KEY: keep_history}
1232-
if reference_ids:
1233-
payload[REFERENCE_IDS_KEY] = reference_ids
1231+
if reference_ids is None:
1232+
reference_ids = []
1233+
payload = {
1234+
KEEP_HISTORY_KEY: keep_history,
1235+
REFERENCE_IDS_KEY: reference_ids,
1236+
}
12341237
response = self._client.make_request(
12351238
payload,
12361239
f"annotation/{self.id}",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = "scale-nucleus"
24-
version = "0.14.5"
24+
version = "0.14.6"
2525
description = "The official Python client library for Nucleus, the Data Platform for AI"
2626
license = "MIT"
2727
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

tests/test_annotation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,9 @@ def test_box_gt_deletion(dataset):
695695

696696
assert response["annotations_processed"] == 1
697697

698-
job = dataset.delete_annotations()
698+
job = dataset.delete_annotations(
699+
reference_ids=[TEST_BOX_ANNOTATIONS[0]["reference_id"]]
700+
)
699701
job.sleep_until_complete()
700702
job_status = job.status()
701703
assert job_status["status"] == "Completed"
@@ -712,7 +714,9 @@ def test_category_gt_deletion(dataset):
712714

713715
assert response["annotations_processed"] == 1
714716

715-
job = dataset.delete_annotations()
717+
job = dataset.delete_annotations(
718+
reference_ids=[TEST_CATEGORY_ANNOTATIONS[0]["reference_id"]]
719+
)
716720
job.sleep_until_complete()
717721
job_status = job.status()
718722
assert job_status["status"] == "Completed"
@@ -731,7 +735,9 @@ def test_multicategory_gt_deletion(dataset):
731735

732736
assert response["annotations_processed"] == 1
733737

734-
job = dataset.delete_annotations()
738+
job = dataset.delete_annotations(
739+
reference_ids=[TEST_MULTICATEGORY_ANNOTATIONS[0]["reference_id"]]
740+
)
735741
job.sleep_until_complete()
736742
job_status = job.status()
737743
assert job_status["status"] == "Completed"

0 commit comments

Comments
 (0)