Skip to content

Commit

Permalink
fix: correct deletion flag which no longer requires a filter type
Browse files Browse the repository at this point in the history
  • Loading branch information
danellecline committed Feb 15, 2025
1 parent 59b1a40 commit 1385832
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/ops/deletions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def del_media_id(model: MediaIdFilterModel, api: tator.api, spec: ProjectS
info(f'Done. Deleted localizations for media {model.media_id} in project {spec.project_name}')


async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_media: bool, **kwargs):
async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_media: bool=False, **kwargs):
"""
Paginated delete of localizations by a given filter
:param allow_empty_media: True if media can be empty - allows for deletion of all localizations across all media
Expand All @@ -50,7 +50,10 @@ async def del_locs(model: Any, spec: ProjectSpec, api: tator.api, allow_empty_me
# Fetch localizations for media 100 at a time
batch_size = min(100, len(media_ids))
for i in range(0, len(media_ids), batch_size):
info(f"Deleting localizations for media {model.media_name} {i} to {i+batch_size} ...")
if hasattr(model, "media_name"):
info(f"Deleting localizations for media {model.media_name} {i} to {i+batch_size} ...")
else:
info(f"Deleting localizations for media {i} to {i+batch_size} ...")
info(kwargs)
# https://www.tator.io/docs/references/tator-py/api
deleted = api.delete_localization_list(
Expand Down
2 changes: 2 additions & 0 deletions src/app/ops/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def __init__(self, name: str):
def prepare_media_kwargs(model:Any, allow_empty_media:bool=False, attribute_prefix=None) -> dict | None:
media_kwargs = {}
debug(f"prepare_media_kwargs model: {model}")
if not hasattr(model, "filter_media"):
return media_kwargs
media_filter_type = FilterType(model.filter_media)

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

0 comments on commit 1385832

Please sign in to comment.