Skip to content

Commit 1385832

Browse files
committed
fix: correct deletion flag which no longer requires a filter type
1 parent 59b1a40 commit 1385832

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/app/ops/deletions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def del_media_id(model: MediaIdFilterModel, api: tator.api, spec: ProjectS
2727
info(f'Done. Deleted localizations for media {model.media_id} in project {spec.project_name}')
2828

2929

30-
async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_media: bool, **kwargs):
30+
async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_media: bool=False, **kwargs):
3131
"""
3232
Paginated delete of localizations by a given filter
3333
:param allow_empty_media: True if media can be empty - allows for deletion of all localizations across all media
@@ -50,7 +50,10 @@ async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_me
5050
# Fetch localizations for media 100 at a time
5151
batch_size = min(100, len(media_ids))
5252
for i in range(0, len(media_ids), batch_size):
53-
info(f"Deleting localizations for media {model.media_name} {i} to {i+batch_size} ...")
53+
if hasattr(model, "media_name"):
54+
info(f"Deleting localizations for media {model.media_name} {i} to {i+batch_size} ...")
55+
else:
56+
info(f"Deleting localizations for media {i} to {i+batch_size} ...")
5457
info(kwargs)
5558
# https://www.tator.io/docs/references/tator-py/api
5659
deleted = api.delete_localization_list(

src/app/ops/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def __init__(self, name: str):
2121
def prepare_media_kwargs(model:Any, allow_empty_media:bool=False, attribute_prefix=None) -> dict | None:
2222
media_kwargs = {}
2323
debug(f"prepare_media_kwargs model: {model}")
24+
if not hasattr(model, "filter_media"):
25+
return media_kwargs
2426
media_filter_type = FilterType(model.filter_media)
2527

2628
if len(model.media_name) == 0 and not allow_empty_media:

0 commit comments

Comments
 (0)