From 657ef7fc2f2e1dfc7a0ce1fe4f1ed7a72a898a3b Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 12 Jul 2022 09:13:51 -0400 Subject: [PATCH] Correctly support element deletion in TileDB Cloud (#220) --- apis/python/src/tiledbsc/tiledb_group.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apis/python/src/tiledbsc/tiledb_group.py b/apis/python/src/tiledbsc/tiledb_group.py index c3179ede4e..a486fb975f 100644 --- a/apis/python/src/tiledbsc/tiledb_group.py +++ b/apis/python/src/tiledbsc/tiledb_group.py @@ -153,12 +153,19 @@ def _add_object(self, obj: TileDBObject, relative: Optional[bool] = None) -> Non obj.uri = self._get_child_uri(obj.name) def _remove_object(self, obj: TileDBObject) -> None: - with self._open("w") as G: - G.remove(obj.name) + self._remove_object_by_name(obj.name) def _remove_object_by_name(self, member_name: str) -> None: - with self._open("w") as G: - G.remove(member_name) + if self.uri.startswith("tiledb://"): + mapping = self._get_member_names_to_uris() + if member_name not in mapping: + raise Exception(f"name {member_name} not present in group {self.uri}") + member_uri = mapping[member_name] + with self._open("w") as G: + G.remove(member_uri) + else: + with self._open("w") as G: + G.remove(member_name) def _get_member_names(self) -> Sequence[str]: """