Esempio n. 1
0
def main():
    runs = {}
    with open(
        os.path.join(testdir, "tests-mcmc.txt"), "rb"
    ) as names:  # open(os.path.join(testdir,'topdirs.p'),'rb') as names:
        # names = cpkl.load(names)
        for name in names:
            meta = setup(name[:-1])
            runs[name[:-4]] = meta
    # make initial plots
    distribute.run_offthread_sync(plots.initial_plots(runs))
    # runs = {'runs':tests}
    global init_runs
    init_runs = runs

    nps = mp.cpu_count()  # -1
    # fork off all of the plotter threads,
    for run_name in runs.keys():
        print ("starting run of " + str(run_name))
        dist = distribute.distribute(plots.all_plotters, start=True, meta=runs[run_name])
        print ("plotter threads for: " + run_name + " started")
        # inject the distribution handler into the metadata object
        runs[run_name].dist = dist
        print ("setting dist on {} to {}".format(run_name, runs[run_name].dist))

    pool = mp.Pool(nps)

    # may add back plot-only functionality later
    keys = runs.keys()  # [run.key.add(t=name) for name in lrange(names)]
    print ("generating {} keys".format(len(keys)))
    pool.map(fsamp, keys)

    for run in runs.keys():
        runs[run].dist.finish()
        print ("ending run of: " + str(run))
Esempio n. 2
0
def main():
    meta = setup()
    p_runs = {key(p=p):perparam(meta, p) for p in lrange(meta.params)}
    s_runs = {p.add(s=s):persurv(meta, p_runs[p], s) for s in lrange(meta.survs) for p in p_runs.keys()}
    n_runs = {s.add(n=n):persamp(meta, s_runs[s], n) for n in xrange(meta.samps) for s in s_runs.keys()}
    i_runs = {n.add(i=i):perinit(meta, n_runs[n], i) for i in lrange(meta.inits) for n in n_runs.keys()}
    runs = {'p_runs': p_runs,
            's_runs': s_runs,
            'n_runs': n_runs,
            'i_runs': i_runs}
    global init_runs
    init_runs = runs

    # make initial plots
    distribute.run_offthread_sync(iplots.initial_plots, meta, runs)

    nps = mp.cpu_count()#-1
    for s_run in s_runs.values():
        print ('starting run of: ' + str(s_run.key))
        # fork off all of the plotter threads,
        dist = distribute.distribute(plots.all_plotters,
                                     start = True,
                                     meta = meta,
                                     p_run = s_run.p_run,
                                     s_run = s_run,
                                     n_runs = s_run.n_runs,
                                     i_runs = [i_run for n_run in s_run.n_runs for i_run in n_run.i_runs])
        # inject the distribution handler into the metadata object
        print ('plotter threads started')
        s_run.dist = dist
        print ('setting dist on {} to {}'.format(s_run, s_run.dist))
        pool = mp.Pool(nps)

        # may add back plot-only functionality later
        keys = [s_run.key.add(n=n, i=i) for i in lrange(meta.inits) for n in xrange(meta.samps)]
        print ('generating {} keys'.format(len(keys)))
        pool.map(fsamp, keys)
        dist.finish()
        print('ending run of: ' + str(s_run.key))