@@ -88,8 +88,12 @@ def setup_collection(self, dims: int):
8888 self .primary .create_collection (
8989 COLLECTION_NAME ,
9090 vectors_config = models .VectorParams (size = dims , distance = models .Distance .COSINE , on_disk = True ),
91- # Disable optimization threads during upload for faster ingestion
92- optimizers_config = models .OptimizersConfigDiff (max_optimization_threads = 0 ),
91+ # Match framework settings - allow optimization during upload
92+ optimizers_config = models .OptimizersConfigDiff (
93+ default_segment_number = 3 ,
94+ max_segment_size = 1_000_000 ,
95+ memmap_threshold = 10_000_000 ,
96+ ),
9397 )
9498
9599 def upload_vectors (self , vectors : np .ndarray ):
@@ -101,22 +105,24 @@ def upload_vectors(self, vectors: np.ndarray):
101105 batch_size = 1024 ,
102106 parallel = 16 ,
103107 )
104- # Re-enable optimization after upload
105- self .primary .update_collection (
106- collection_name = COLLECTION_NAME ,
107- optimizer_config = models .OptimizersConfigDiff (max_optimization_threads = 100_000 ),
108- )
109108
110109 def wait_for_green (self , timeout : int = 1800 ):
111110 print ("Waiting for green status..." , end = "" , flush = True )
112- start = time .time ()
113- while time .time () - start < timeout :
111+ wait_time = 5.0
112+ total = 0
113+ while total < timeout :
114+ time .sleep (wait_time )
115+ total += wait_time
116+ info = self .primary .get_collection (COLLECTION_NAME )
117+ if info .status != models .CollectionStatus .GREEN :
118+ print ("." , end = "" , flush = True )
119+ continue
120+ # Double-check: status can briefly flip to GREEN during optimization
121+ time .sleep (wait_time )
114122 info = self .primary .get_collection (COLLECTION_NAME )
115123 if info .status == models .CollectionStatus .GREEN :
116- print (f" done ({ time . time () - start :.1f} s)" )
124+ print (f" done ({ total :.1f} s)" )
117125 return
118- time .sleep (1 )
119- print ("." , end = "" , flush = True )
120126 print (f" timeout after { timeout } s" )
121127
122128 def get_collection_cluster_info (self ) -> dict :
0 commit comments