assert pool
// the ctx manager will close and remove the processes, so we have to start new ones every time...
with pool:
res = pool(task_iter)
// if n_jobs=1 don"t invoke the pool, but directly dispatch the iterator
else:
res = []
for estimator, param_set in zip(estimators, param_sets):
After Change
if n_jobs > 1:
// iterate over parameter settings
task_iter = ((estimator,
param_set, X,
evaluate,
evaluate_args,
failfast)
for estimator, param_set in zip(estimators, param_sets))
from pathos.multiprocessing import Pool as Parallel
pool = Parallel(processes=n_jobs)
args = list(task_iter)
if progress_reporter is not None:
progress_reporter._progress_register(len(estimators), stage=0, description="estimating %s" % str(estimator.__class__.__name__))
from pyemma._base.model import SampledModel
for a in args:
if isinstance(a[0], SampledModel):
a[0].show_progress = False
def callback(_):
progress_reporter._progress_update(1, stage=0)
with pool:
res_async = [pool.apply_async(_estimate_param_scan_worker, a, callback=callback) for a in args]
res = [x.get() for x in res_async]
// if n_jobs=1 don"t invoke the pool, but directly dispatch the iterator