-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kerl/python-remote-storage-ci' of github.com:single-cel…
…l-data/TileDB-SOMA into kerl/python-remote-storage-ci
- Loading branch information
Showing
3 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import datetime | ||
import os | ||
import pathlib | ||
from typing import Tuple | ||
|
||
import tiledb.cloud | ||
|
||
# For cloud: | ||
# * Create with timestamp | ||
# * Delete on teardown | ||
# For local: | ||
# * Create without timestamp | ||
# o Only remove the URI from a _previous_ run (if any) | ||
# * Do not delete on teardown -- so developers can look at the data | ||
|
||
|
||
def util_make_uri(dirname: str, basename: str) -> Tuple[str, str]: | ||
if os.getenv("TILEDB_SOMA_CLOUD_TEST_LOCAL_PATHS") is None: | ||
user_profile = tiledb.cloud.user_profile() | ||
namespace = user_profile.username | ||
# Contains the "s3://..." prefix and a trailing slash | ||
# Note that double slashes can cause group-creation failures | ||
# so we need to carefully strip them out. | ||
bucket = (user_profile.default_s3_path).rstrip("/") | ||
|
||
stamp = datetime.datetime.today().strftime("%Y%m%d-%H%M%S") | ||
creation_uri = f"tiledb://{namespace}/{bucket}/{dirname}/{basename}_{stamp}" | ||
readback_uri = f"tiledb://{namespace}/{basename}_{stamp}" | ||
|
||
return (creation_uri, readback_uri) | ||
|
||
else: | ||
uri = f"/tmp/tiledbsoma-cloud-test/{dirname}/{basename}" | ||
pathlib.Path(os.path.dirname(uri)).mkdir(parents=True, exist_ok=True) | ||
return (uri, uri) | ||
|
||
|
||
def util_tear_down_uri(uri): | ||
if uri.startswith("tiledb://"): | ||
tiledb.cloud.groups.delete(uri=uri, recursive=True) | ||
# Delete local URIs only on _next_ run, so devs can inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters