Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Jul 16, 2022
1 parent 5da109d commit 79928b7
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions apis/python/src/tiledbsc/tiledb_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ def _open(self, mode: str = "r") -> tiledb.Group:
It works asa `with self._open() as G:` as well as `G = self._open(); ...; G.close()`.
"""
assert mode in ("r", "w")
if mode == "r" and not self.exists():
raise Exception(f"Does not exist: {self.uri}")
# #126 no longer needed :D
# if mode == "r" and not self.exists():
# raise Exception(f"Does not exist: {self.uri}")
# This works in with-open-as contexts because tiledb.Group has __enter__ and __exit__ methods.
return tiledb.Group(self.uri, mode=mode, ctx=self._ctx)

Expand All @@ -100,7 +101,26 @@ def _get_child_uris(self, member_names: Sequence[str]) -> Dict[str, str]:
is reduced when we ask for all group-element name-to-URI mappings in a single
request to the REST server.
"""
if not self.exists():

# XXX COMMENT
try:
answer = {}

mapping = self._get_member_names_to_uris()
for member_name in member_names:
if member_name in mapping:
answer[member_name] = mapping[member_name]
else:
# Truly a slash, not os.path.join:
# * If the client is Linux/Un*x/Mac, it's the same of course
# * On Windows, os.path.sep is a backslash but backslashes are _not_ accepted for S3 or
# tiledb-cloud URIs, whereas in Windows versions for years now forward slashes _are_
# accepted for local-disk paths.
# This means forward slash is acceptable in all cases.
answer[member_name] = self.uri + "/" + member_name

return answer
except: # XXX ONLY FOR THE RIGHT EXCEPTION
# Group not constructed yet. Here, appending "/" and name is appropriate in all
# cases: even for tiledb://... URIs, pre-construction URIs are of the form
# tiledb://namespace/s3://something/something/soma/membername.
Expand All @@ -109,23 +129,6 @@ def _get_child_uris(self, member_names: Sequence[str]) -> Dict[str, str]:
for member_name in member_names
}

answer = {}

mapping = self._get_member_names_to_uris()
for member_name in member_names:
if member_name in mapping:
answer[member_name] = mapping[member_name]
else:
# Truly a slash, not os.path.join:
# * If the client is Linux/Un*x/Mac, it's the same of course
# * On Windows, os.path.sep is a backslash but backslashes are _not_ accepted for S3 or
# tiledb-cloud URIs, whereas in Windows versions for years now forward slashes _are_
# accepted for local-disk paths.
# This means forward slash is acceptable in all cases.
answer[member_name] = self.uri + "/" + member_name

return answer

def _get_child_uri(self, member_name: str) -> str:
"""
Computes the URI for a child of the given object. For local disk, S3, and
Expand Down

0 comments on commit 79928b7

Please sign in to comment.