99
1010MINIMUM_ACCURACY = 0.85
1111
12+
1213class CloudTests (unittest .TestCase ):
13- def setUp (self ):
14- super ().setUp ()
14+ flat_index_uri = ""
15+ ivf_flat_index_uri = ""
16+
17+ @classmethod
18+ def setUpClass (cls ):
1519 tiledb .cloud .login (token = os .getenv ("TILEDB_REST_TOKEN" ))
16- self . namespace , storage_path , _ = groups ._default_ns_path_cred ()
20+ namespace , storage_path , _ = groups ._default_ns_path_cred ()
1721 storage_path = storage_path .replace ("//" , "/" ).replace ("/" , "//" , 1 )
1822 rand_name = random_name ("vector_search" )
19- self .test_path = f"tiledb://{ self .namespace } /{ storage_path } /{ rand_name } "
20- self .config = tiledb .cloud .Config ()
21- self .config_dict = self .config .dict ()
22- self .flat_index_uri = f"{ self .test_path } /test_flat_array"
23- self .ivf_flat_index_uri = f"{ self .test_path } /test_ivf_flat_array"
23+ test_path = f"tiledb://{ namespace } /{ storage_path } /{ rand_name } "
24+ cls .flat_index_uri = f"{ test_path } /test_flat_array"
25+ cls .ivf_flat_index_uri = f"{ test_path } /test_ivf_flat_array"
2426
25- def tearDown (self ):
26- vs .Index .delete_index (uri = self .flat_index_uri , config = self .config )
27- vs .Index .delete_index (uri = self .ivf_flat_index_uri , config = self .config )
27+ @classmethod
28+ def tearDownClass (cls ):
29+ vs .Index .delete_index (uri = cls .flat_index_uri , config = tiledb .cloud .Config ())
30+ vs .Index .delete_index (uri = cls .ivf_flat_index_uri , config = tiledb .cloud .Config ())
2831
2932 def test_cloud_flat (self ):
3033 source_uri = "tiledb://TileDB-Inc/sift_10k"
3134 queries_uri = "test/data/siftsmall/siftsmall_query.fvecs"
3235 gt_uri = "test/data/siftsmall/siftsmall_groundtruth.ivecs"
33- index_uri = self .flat_index_uri
36+ index_uri = CloudTests .flat_index_uri
3437 k = 100
3538 nqueries = 100
3639
@@ -41,7 +44,7 @@ def test_cloud_flat(self):
4144 index_type = "FLAT" ,
4245 index_uri = index_uri ,
4346 source_uri = source_uri ,
44- config = self . config_dict ,
47+ config = tiledb . cloud . Config (). dict () ,
4548 mode = Mode .BATCH ,
4649 )
4750 _ , result_i = index .query (query_vectors , k = k )
@@ -51,7 +54,7 @@ def test_cloud_ivf_flat(self):
5154 source_uri = "tiledb://TileDB-Inc/sift_10k"
5255 queries_uri = "test/data/siftsmall/siftsmall_query.fvecs"
5356 gt_uri = "test/data/siftsmall/siftsmall_groundtruth.ivecs"
54- index_uri = self .ivf_flat_index_uri
57+ index_uri = CloudTests .ivf_flat_index_uri
5558 k = 100
5659 partitions = 100
5760 nqueries = 100
@@ -66,7 +69,7 @@ def test_cloud_ivf_flat(self):
6669 source_uri = source_uri ,
6770 partitions = partitions ,
6871 input_vectors_per_work_item = 5000 ,
69- config = self . config_dict ,
72+ config = tiledb . cloud . Config (). dict () ,
7073 mode = Mode .BATCH ,
7174 )
7275 _ , result_i = index .query (query_vectors , k = k , nprobe = nprobe )
0 commit comments