From 7971580371c11e2cf451cd3f8ebeb381df15c425 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Fri, 15 Jul 2022 12:27:06 -0400 Subject: [PATCH] no exists-caching --- apis/python/src/tiledbsc/soma.py | 11 +---------- apis/python/src/tiledbsc/soma_collection.py | 4 +--- apis/python/src/tiledbsc/tiledb_group.py | 11 ++--------- apis/python/tools/ingestor | 2 -- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/apis/python/src/tiledbsc/soma.py b/apis/python/src/tiledbsc/soma.py index 6b921e0511..1ea318a1de 100644 --- a/apis/python/src/tiledbsc/soma.py +++ b/apis/python/src/tiledbsc/soma.py @@ -89,16 +89,7 @@ def __init__( ctx=ctx, ) - # obs_uri = self._get_child_uri("obs") # See comments in that function - # var_uri = self._get_child_uri("var") - # X_uri = self._get_child_uri("X") - # obsm_uri = self._get_child_uri("obsm") - # varm_uri = self._get_child_uri("varm") - # obsp_uri = self._get_child_uri("obsp") - # varp_uri = self._get_child_uri("varp") - # raw_uri = self._get_child_uri("raw") - # uns_uri = self._get_child_uri("uns") - + # TODO: COMMENT member_names = ["obs", "var", "X", "obsm", "varm", "obsp", "varp", "raw", "uns"] child_uris = self._get_child_uris(member_names) # See comments in that function diff --git a/apis/python/src/tiledbsc/soma_collection.py b/apis/python/src/tiledbsc/soma_collection.py index b0763d2c94..a4dd81c1b5 100644 --- a/apis/python/src/tiledbsc/soma_collection.py +++ b/apis/python/src/tiledbsc/soma_collection.py @@ -61,7 +61,7 @@ def __init__( ctx=ctx, ) - self._somas = None + self._somas = {} # ---------------------------------------------------------------- def __repr__(self) -> str: @@ -125,8 +125,6 @@ def __iter__(self) -> Iterator[SOMA]: """ Implements `for soma in soco: ...` """ - if self._somas is None: - self._somas = {} for name, uri in self._get_member_names_to_uris().items(): if name not in self._somas: self._somas[name] = SOMA(uri=uri, name=name, parent=self, ctx=self._ctx) diff --git a/apis/python/src/tiledbsc/tiledb_group.py b/apis/python/src/tiledbsc/tiledb_group.py index bb1a7f788b..252fedda3b 100644 --- a/apis/python/src/tiledbsc/tiledb_group.py +++ b/apis/python/src/tiledbsc/tiledb_group.py @@ -15,7 +15,6 @@ class TileDBGroup(TileDBObject): Wraps groups from TileDB-Py by retaining a URI, options, etc. """ - _cached_exists: Optional[bool] _cached_member_names_to_uris: Optional[Dict[str, str]] def __init__( @@ -33,7 +32,6 @@ def __init__( See the TileDBObject constructor. """ super().__init__(uri, name, parent=parent, soma_options=soma_options, ctx=ctx) - self._cached_exists = None self._cached_member_names_to_uris = None def exists(self) -> bool: @@ -43,11 +41,8 @@ def exists(self) -> bool: SOMA has been populated but doesn't have this member (e.g. not all SOMAs have a `varp`). """ # TODO: NOTE WHAT IF VFS.DELETE AFTER INSTANTIATION - if self._cached_exists is None: - self._cached_exists = bool( - tiledb.object_type(self.uri, ctx=self._ctx) == "group" - ) - return self._cached_exists + # TODO: NON-CACHEABLE AND WHY + return tiledb.object_type(self.uri, ctx=self._ctx) == "group" def create_unless_exists(self) -> None: """ @@ -89,7 +84,6 @@ def _open(self, mode: str = "r") -> tiledb.Group: This is just a convenience wrapper around tiledb group-open. It works asa `with self._open() as G:` as well as `G = self._open(); ...; G.close()`. """ - print("OPEN", self.uri) assert mode in ("r", "w") if mode == "r" and not self.exists(): raise Exception(f"Does not exist: {self.uri}") @@ -236,7 +230,6 @@ def _get_member_names_to_uris(self) -> Dict[str, str]: if self._cached_member_names_to_uris is None: with self._open("r") as G: self._cached_member_names_to_uris = {obj.name: obj.uri for obj in G} - print("GMN2U", self.uri) return self._cached_member_names_to_uris def show_metadata(self, recursively: bool = True, indent: str = "") -> None: diff --git a/apis/python/tools/ingestor b/apis/python/tools/ingestor index db307a0e05..9662b18f62 100755 --- a/apis/python/tools/ingestor +++ b/apis/python/tools/ingestor @@ -231,8 +231,6 @@ def ingest_one( f"Already exists; replacing: {output_path}" ) shutil.rmtree(output_path) # Overwrite - # TODO: COMMENT - soma = tiledbsc.SOMA(uri=output_path, soma_options=soma_options) else: raise Exception( "Internal coding error in --ifexists handling.", ifexists, "<"