@@ -41,16 +41,29 @@ def __init__(self, uri: str, ctx: Optional[Ctx] = None):
4141 # Windows paths produce single letter scheme matching the drive letter
4242 # Unix absolute path produce an empty scheme
4343 self ._ctx = ctx
44+ self ._group_exists = False
45+
46+ # At construction time we consider it as valid, this value will be valuated upon
47+ # opening the Group under a context
48+ self ._valid_group = True
4449 if len (parsed_uri .scheme ) < 2 or parsed_uri .scheme == "file" :
4550 uri = str (Path (parsed_uri .path ).resolve ()).replace ("\\ " , "/" )
4651 if tiledb .object_type (uri , ctx = ctx ) != "group" :
4752 tiledb .group_create (uri , ctx = ctx )
53+ else :
54+ # The destination path is already a group thus we check the validity of
55+ # a previously successful ingestion by checking the existence of
56+ # the ACK metadata KV
57+ self ._group_exists = True
4858 self ._uri = uri if uri .endswith ("/" ) else uri + "/"
4959 self ._is_cloud = parsed_uri .scheme == "tiledb"
5060
5161 def __enter__ (self ) -> ReadWriteGroup :
5262 self .r_group = tiledb .Group (self ._uri , "r" , ctx = self ._ctx )
5363 self .w_group = tiledb .Group (self ._uri , "w" , ctx = self ._ctx )
64+ self .m_group = tiledb .Group (self ._uri , "m" , ctx = self ._ctx )
65+ if self ._group_exists :
66+ self ._valid_group = self .r_group .meta .get ("valid" , False )
5467 return self
5568
5669 def __exit__ (self , exc_type : Any , exc_val : Any , exc_tb : Any ) -> None :
@@ -93,6 +106,10 @@ def get_or_create(self, name: str, schema: tiledb.ArraySchema) -> Tuple[str, boo
93106 self .w_group .add (name , name , relative = True )
94107 return uri , create
95108
109+ @property
110+ def valid_group (self ) -> bool :
111+ return self ._valid_group
112+
96113
97114def validate_ingestion (uri : str , ctx : tiledb .Ctx = None ) -> bool :
98115 """
0 commit comments