from ezcache_new import ezcache as ez
from numpy.random import rand
import time

def f(z):
    #a
    import time
    time_to_sleep = np.random.rand()*5
    time.sleep(time_to_sleep)
    return z**3
    #import numpy as np
    #np.random.seed(z)
    #return np.sum(np.random.randn(10))
d = '/home/domke/work1/divide_and_couple'

ezf = ez(f,directory=d)

for a in range(10):
    print('running on ', a)
    ezf.run(a)

ezf.wait_for_complete()

for a in range(10):
    print('results for',a,ezf.get(a))
#time.sleep(5)

# ezf = ez(f,directory=d)

# print('a squared',ezf.get(a))