@@ -1125,8 +1125,8 @@ def __init__(self, seed_mol: Chem.rdchem.Mol, crem_db_path: str, costfunc: objec
11251125 self .costfunc_kwargs = costfunc_kwargs
11261126 self .pop = [self .InitIndividual ]
11271127
1128- def __call__ (self , njobs : int = 1 , pick : int = None ):
1129- """Call deffinition
1128+ def __call__ (self , njobs : int = 1 , pick : int = None , runner : Optional [ Runner ] = None ):
1129+ """Call definition
11301130
11311131 Parameters
11321132 ----------
@@ -1135,7 +1135,16 @@ def __call__(self, njobs: int = 1, pick: int = None):
11351135 pick : int, optional
11361136 How many molecules take from the generated throgh the grow_mol CReM operation,
11371137 by default None which means all generated.
1138+ runner: Runner, optional
1139+ Providing this parameter instead of njobs allows execution on a cluster with Dask. Few other modes
1140+ of executions are also available, but useful mostly for debugging and profiling.
11381141 """
1142+ if njobs > 1 :
1143+ assert runner is None , "Both njobs > 1 and runner have been specified. Please use only one of the parameters."
1144+
1145+ if runner is None :
1146+ runner = Runner (RunnerMode .MULTIPROCESSING , process_count = njobs )
1147+
11391148 # Check version of moldrug
11401149 if self .__moldrug_version != __version__ :
11411150 warn (f"{ self .__class__ .__name__ } was initilized with moldrug-{ self .__moldrug_version } "
@@ -1163,7 +1172,7 @@ def __call__(self, njobs: int = 1, pick: int = None):
11631172 args_list .append ((individual , kwargs_copy ))
11641173
11651174 print ('Calculating cost function...' )
1166- self .pop = parallel_execution_multiprocessing (self .__costfunc__ , args_list , njobs )
1175+ self .pop = runner . run (self .__costfunc__ , args_list )
11671176
11681177 # Clean directory
11691178 costfunc_jobs_tmp_dir .cleanup ()
@@ -1412,7 +1421,6 @@ def __call__(self, njobs: int = 1, runner: Optional[Runner] = None):
14121421 ----------
14131422 njobs : int, optional
14141423 The number of jobs for parallelization, the module multiprocessing will be used, by default 1,
1415-
14161424 runner: Runner, optional
14171425 Providing this parameter instead of njobs allows execution on a cluster with Dask. Few other modes
14181426 of executions are also available, but useful mostly for debugging and profiling.
0 commit comments