In [1]:
cd ~/research/TP-AGBcalib/code/TPAGB-calib/
In [2]:
from IPython import parallel
import sfh_tests_multi_proc
import itertools
import time
In [3]:
%pylab tk
In [4]:
def caller(vSFH, vsfh_kws):
return vSFH.vary_the_SFH(**vsfh_kws)
In [5]:
clients = parallel.Client()
clients.block = False
In [6]:
clients[:].execute('cd ~/research/TP-AGBcalib/code/TPAGB-calib/')
clients[:].execute('import sfh_tests_multi_proc')
Out[6]:
In [39]:
reload(sfh_tests_multi_proc)
clients[:].execute('reload(sfh_tests_multi_proc)')
Out[39]:
In [39]:
targets = ['scl-de1', 'ddo71', 'hs117', 'kkh37', 'ngc2976-deep', 'ddo78']
targets = ['scl-de1']
cmd_inputs = ['cmd_input_CAF09_S_NOV13.dat', 'cmd_input_CAF09_S_NOV13eta0.dat', 'cmd_input_CAF09_S_OCT13.dat']
nsfhs = 50
In [40]:
vSFHs, vsfh_kws = sfh_tests_multi_proc.prepare_vsfh_run(targets, cmd_inputs, nsfhs)
In [87]:
#vsfh_kws['make_many_kw'] = {'mk_tri_sfh_kw': {'dry_run': False}}
In [41]:
# find a better way to run this all at once, rather then need to do to steps when nvsfhs > nprocs.
nprocs = len(clients)
nvsfhs = len(vSFHs)
ntimes = np.min([nprocs, nvsfhs])
ndiff = np.abs(nvsfhs - nprocs)
In [42]:
nprocs, nvsfhs, ntimes, ndiff
Out[42]:
In [11]:
# debug w/o parallel
#res = [caller(vSFHs[i], vsfh_kws) for i in range(ntimes)]
In [46]:
res = [clients[i].apply(caller, vSFHs[i], vsfh_kws,) for i in range(ntimes)]
while False in [r.ready() for r in res]:
time.sleep(900)
[vSFHs[i].write_results(res[i].result) for i in range(ntimes)]
res2 = [clients[i].apply(caller, vSFHs[i+ntimes], vsfh_kws,) for i in range(ndiff)]
while False in [r.ready() for r in res2]:
time.sleep(900)
[vSFHs[i+ntimes].write_results(res2[i].result) for i in range(ndiff)]
Out[46]:
In [ ]: