Skip to content

Commit

Permalink
appease mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariana Barzinpour committed Apr 24, 2024
1 parent 1013a6b commit 8952a33
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions datacube/index/memory/_products.py
Expand Up @@ -116,10 +116,12 @@ def update(self, product: Product,
return cast(Product, self.get_by_name(product.name))

def delete(self, product: Product):
ids: Iterable[UUID] = self._index.datasets.search_returning(archived=None, product=product.name)
self._index.datasets.purge(ids)
datasets = self._index.datasets.search_returning(('id',), archived=None, product=product.name)
if datasets:
self._index.datasets.purge([ds.id for ds in datasets]) # type: ignore[attr-defined]

del self.by_id[product.id]
if product.id is not None:
del self.by_id[product.id]
del self.by_name[product.name]

def get_unsafe(self, id_: int) -> Product:
Expand Down
2 changes: 1 addition & 1 deletion datacube/index/postgis/_products.py
Expand Up @@ -242,7 +242,7 @@ def delete(self, product: Product):
"""
# First find and delete all related datasets
product_datasets = self._index.datasets.search_returning(('id',), archived=None, product=product.name)
self._index.datasets.purge([ds.id for ds in product_datasets])
self._index.datasets.purge([ds.id for ds in product_datasets]) # type: ignore[attr-defined]

# Now we can safely delete the Product
with self._db_connection() as conn:
Expand Down
2 changes: 1 addition & 1 deletion datacube/index/postgres/_products.py
Expand Up @@ -234,7 +234,7 @@ def delete(self, product: Product):
"""
# First find and delete all related datasets
product_datasets = self._index.datasets.search_returning(('id',), archived=None, product=product.name)
self._index.datasets.purge([ds.id for ds in product_datasets])
self._index.datasets.purge([ds.id for ds in product_datasets]) # type: ignore[attr-defined]

# Now we can safely delete the Product
# Pass along metadata type information as well to update indexes/views
Expand Down
3 changes: 2 additions & 1 deletion datacube/scripts/product.py
Expand Up @@ -161,7 +161,8 @@ def delete_products(index: Index, force: bool, dry_run: bool, product_names: Lis
for name in product_names:
active_ds = list(index.datasets.search_returning(('id',), archived=False, product=name))
if len(active_ds):
click.echo(f"Product {name} has active datasets: {' '.join([str(ds.id) for ds in active_ds])}")
click.echo(f"Product {name} has active datasets: "
f"{' '.join([str(ds.id) for ds in active_ds])}") # type: ignore[attr-defined]
active_product = True

if active_product:
Expand Down

0 comments on commit 8952a33

Please sign in to comment.