Skip to content

Commit

Permalink
add dataset deletion API
Browse files Browse the repository at this point in the history
  • Loading branch information
awenocur committed Sep 6, 2024
1 parent 6282fc3 commit f278a6a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions apis/python/src/tiledbvcf/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@

from . import libtiledbvcf

try:
import tiledb.cloud

can_use_cloud = True
except Exception:
can_use_cloud = False

try:
import tiledb

can_use_embedded = True
except Exception:
can_use_embebbed = False

DEFAULT_ATTRS = [
"sample_name",
"contig",
Expand Down Expand Up @@ -684,6 +698,23 @@ def create_dataset(
# This call throws an exception if the dataset already exists.
self.writer.create_dataset()

def delete_dataset(self):
is_cloud_uri = self.uri.startswith("tiledb:")
if is_cloud_uri:
if can_use_cloud:
tiledb.cloud.asset.delete(self.uri)
else:
raise Exception(
"Deleting this dataset requires the tiledb.cloud package"
)
else:
if can_use_embedded:
with tiledb.scope_ctx(self.cfg):
with tiledb.Group(self.uri, "m") as g:
g.delete(recursive=True)
else:
raise Exception("Deleting this dataset requires the tiledb package")

def ingest_samples(
self,
sample_uris: List[str] = None,
Expand Down

0 comments on commit f278a6a

Please sign in to comment.