2121from .plot import plot_kdes_project , plot_map_project
2222
2323
24+ def _load_well_from_las (filepath , remap = None , funcs = None , data = True , req = None , alias = None , encoding = None , printfname = None , index = None , ** kwargs ):
25+ """Helper function for concurrent well loading."""
26+ try :
27+ # Handle URLs directly in the subprocess to avoid file handle issues
28+ # when passing file objects between processes
29+ return Well .from_las (filepath ,
30+ remap = remap ,
31+ funcs = funcs ,
32+ data = data ,
33+ req = req ,
34+ alias = alias ,
35+ encoding = encoding ,
36+ printfname = printfname ,
37+ index = index ,
38+ ** kwargs )
39+ except Exception as e :
40+ print (f"Error loading well { filepath } : { e } " )
41+ return None
42+
43+
2444class Project (object ):
2545 """
2646 Just a list of Well objects.
@@ -163,6 +183,9 @@ def from_las(cls,
163183 Returns:
164184 project. The project object.
165185 """
186+ import concurrent .futures
187+ from tqdm import tqdm
188+
166189 if max is None :
167190 max = 1e12
168191 if (req is not None ) and (alias is None ):
@@ -180,20 +203,24 @@ def from_las(cls,
180203 else :
181204 uris = path # It's a list-like of files and/or URLs.
182205
183- wells = [Well .from_las (f ,
184- remap = remap ,
185- funcs = funcs ,
186- data = data ,
187- req = req ,
188- alias = alias ,
189- encoding = encoding ,
190- printfname = printfname ,
191- index = index ,
192- ** kwargs ,
193- )
194- for i , f in tqdm (enumerate (uris )) if i < max ]
195-
196- return cls (list (filter (None , wells )))
206+ # Limit to the maximum number of wells requested
207+ uris = [f for i , f in enumerate (uris ) if i < max ]
208+
209+ wells = []
210+ with concurrent .futures .ProcessPoolExecutor () as executor :
211+ # Submit all tasks and create a mapping of futures to original indices
212+ future_to_idx = {executor .submit (_load_well_from_las , uri , remap = remap , funcs = funcs , data = data , req = req , alias = alias , encoding = encoding , printfname = printfname , index = index , ** kwargs ): i for i , uri in enumerate (uris )}
213+
214+ # Use tqdm to show a progress bar
215+ for future in tqdm (concurrent .futures .as_completed (future_to_idx ), total = len (uris ), desc = "Loading wells" ):
216+ try :
217+ well = future .result ()
218+ if well is not None :
219+ wells .append (well )
220+ except Exception as e :
221+ print (f"Error loading well: { e } " )
222+
223+ return cls (wells , source = path )
197224
198225 def add_canstrat_striplogs (self , path , uwi_transform = None , name = 'canstrat' ):
199226 """
0 commit comments