def test_iteratetask(): jugfile = os.path.join(_jugdir, 'iteratetask.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() assert space['t0'].value() == 0 assert space['t1'].value() == 2 assert space['t2'].value() == 4
def test_no_load(): jugfile = os.path.join(_jugdir, 'no_load.py') store, space = jug.jug.init(jugfile, 'dict_store') x = space['x'] assert not x.can_run() simple_execute() assert x.can_run()
def test_w_barrier(): store, space = jug.jug.init('jug/tests/jugfiles/compound_wbarrier.py', 'dict_store') simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/compound_wbarrier.py', store) simple_execute() assert 'sixteen' in space assert space['sixteen'].result == 16
def test_bvalue(): store, space = jug.jug.init('jug/tests/jugfiles/bvalue.py', 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/bvalue.py', store) assert 'four' in space assert space['four'] == 4
def test_iteratetask(): store, space = jug.jug.init('jug/tests/jugfiles/iteratetask.py', 'dict_store') simple_execute() assert space['t0'].value() == 0 assert space['t1'].value() == 2 assert space['t2'].value() == 4
def test_jug_check(): N = 16 A = [False for i in range(N)] def setAi(i): A[i] = True return i def first_two(one, two): return one+two setall = [Task(setAi, i) for i in range(N)] check = Task(first_two, setall[0], setall[1]) check2 = Task(first_two, setall[1], setall[2]) store = dict_store() jug.task.Task.store = store e = None try: jug.jug.check(store, default_options) except SystemExit as e: pass assert e is not None assert e.code == 1 savedtasks = jug.task.alltasks[:] simple_execute() jug.task.alltasks = savedtasks e = None try: jug.jug.check(store, default_options) assert False except SystemExit as e: pass assert e is not None assert e.code == 0
def test_tasklets(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') simple_execute() assert space['t0'].value() == 0 assert space['t2'].value() == 4 assert space['t0_2'].value() == 4 assert space['t0_2_1'].value() == 5
def test_taskgenerator_map(): jugfile = os.path.join(_jugdir, 'mapgenerator.py') store, space = jug.jug.init(jugfile, 'dict_store') assert not space['s'].can_run() simple_execute() assert len(value(space['v2s'])) == 16 assert len(value(space['v4s'])) == 16
def test_tasklet_slice_dependencies(): jugfile = os.path.join(_jugdir, 'slice_task.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() assert space['z2'].value() == 0 assert space['z2_2'].value() == 0 assert space['z3'].value() == 1
def test_currymap(): np.random.seed(33) jug.task.Task.store = dict_store() A = np.random.rand(100) ts = jug.mapreduce.currymap(mapper2, list(zip(A, A))) simple_execute() assert np.allclose(np.array(value(ts)), A * 2)
def test_cleanup(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') simple_execute() h = jug.task.alltasks[-1].hash() l = store.getlock(h) del jug.task.alltasks[-1] assert store.can_load(h) assert not l.is_locked() l.get() assert store.can_load(h) assert l.is_locked() opts = Options(default_options) opts.cleanup_locks_only = True jug.jug.cleanup(store, opts) assert store.can_load(h) assert not l.is_locked() opts.cleanup_locks_only = False jug.jug.cleanup(store, opts) assert not store.can_load(h) assert not l.is_locked()
def test_describe(): jugfile = os.path.join(_jugdir, 'simple.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() t = space['vals'][0] desc = describe(t) assert len(desc['args']) == len(t.args)
def test_currymap(): np.random.seed(33) jug.task.Task.store = dict_store() A = np.random.rand(100) ts = jug.mapreduce.currymap(mapper2, list(zip(A,A))) simple_execute() assert np.allclose(np.array(value(ts)) , A*2)
def test_describe(): jugfile = 'jug/tests/jugfiles/simple.py' store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() t = space['vals'][0] desc = describe(t) assert len(desc['args']) == len(t.args)
def test_bvalue(): store, space = jug.jug.init("jug/tests/jugfiles/bvalue.py", "dict_store") assert "four" not in space simple_execute() store, space = jug.jug.init("jug/tests/jugfiles/bvalue.py", store) assert "four" in space assert space["four"] == 4
def test_jug_check(): N = 16 A = [False for i in range(N)] def setAi(i): A[i] = True return i def first_two(one, two): return one+two setall = [Task(setAi, i) for i in range(N)] check = Task(first_two, setall[0], setall[1]) check2 = Task(first_two, setall[1], setall[2]) store = dict_store() jug.task.Task.store = store try: jug.jug.check(store, default_options) except SystemExit as e: assert e.code == 1 else: assert False savedtasks = jug.task.alltasks[:] simple_execute() jug.task.alltasks = savedtasks try: jug.jug.check(store, default_options) assert False except SystemExit as e: assert e.code == 0 else: assert False
def test_builtin_function(): import numpy as np store, space = jug.jug.init('jug/tests/jugfiles/builtin_function.py', 'dict_store') simple_execute() a8 = jug.task.value(space['a8']) assert np.all(a8 == np.arange(8))
def test_builtin_function(): import numpy as np jugfile = os.path.join(_jugdir, 'builtin_function.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() a8 = jug.task.value(space['a8']) assert np.all(a8 == np.arange(8))
def test_w_barrier(): jugfile = os.path.join(_jugdir, 'compound_wbarrier.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() store, space = jug.jug.init(jugfile, store) simple_execute() assert 'sixteen' in space assert space['sixteen'].result == 16
def test_tasklet(): jugfile = os.path.join(_jugdir, 'sleep_until_tasklet.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert jug.subcommands.check._check_or_sleep_until(store, False) == 0 assert jug.subcommands.check._check_or_sleep_until(store, True) == 0
def test_bvalue(): jugfile = os.path.join(_jugdir, 'bvalue.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert 'four' in space assert space['four'] == 4
def test_mapreduce_barrier(): store, space = jug.jug.init('jug/tests/jugfiles/barrier_mapreduce.py', 'dict_store') assert 'values' not in space simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/barrier_mapreduce.py', store) assert 'values' in space assert space['values'] == product(range(20)) simple_execute()
def test_bvalue(): jugfile = find_test_jugfile('bvalue.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert 'four' in space assert space['four'] == 4
def test_non_simple(): store, space = jug.jug.init('jug/tests/jugfiles/compound.py', 'dict_store') simple_execute() assert 'sixteen' in space assert space['sixteen'].result == 16 store, space = jug.jug.init('jug/tests/jugfiles/compound.py', store) assert 'sixteen' in space assert space['sixteen'].result == 16
def test_map(): np.random.seed(33) jug.task.Task.store = dict_store() A = np.random.rand(10000) ts = jug.mapreduce.map(mapper, A) simple_execute() ts = value(ts) assert np.all(ts == np.array(list(map(mapper, A))))
def test_tasklet(): jugfile = 'jug/tests/jugfiles/sleep_until_tasklet.py' store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert jug.jug._check_or_sleep_until(store, False) == 0 assert jug.jug._check_or_sleep_until(store, True) == 0
def test_map(): np.random.seed(33) jug.task.Task.store = dict_store() A = np.random.rand(10000) ts = jug.mapreduce.map(mapper, A) simple_execute() ts = value(ts) assert np.all(ts == np.array(list(map(mapper,A))))
def test_tasklet(): jugfile = os.path.join(_jugdir, 'sleep_until_tasklet.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert jug.jug._check_or_sleep_until(store, False) == 0 assert jug.jug._check_or_sleep_until(store, True) == 0
def test_mapreduce_barrier(): store, space = jug.jug.init("jug/tests/jugfiles/barrier_mapreduce.py", "dict_store") assert "values" not in space simple_execute() store, space = jug.jug.init("jug/tests/jugfiles/barrier_mapreduce.py", store) assert "values" in space assert space["values"] == product(list(range(20))) simple_execute()
def test_tasklets(): jugfile = os.path.join(_jugdir, 'tasklets.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() assert space['t0'].value() == 0 assert space['t2'].value() == 4 assert space['t0_2'].value() == 4 assert space['t0_2_1'].value() == 5
def test_nocache(): store, space = jug.jug.init('jug/tests/jugfiles/simple.py', 'dict_store') simple_execute() options = default_options.copy() options.jugdir = store options.jugfile = 'jug/tests/jugfiles/simple.py' options.verbose = 'quiet' assert status.status(options) == 8 * 4
def test_mapreduce_barrier(): jugfile = os.path.join(_jugdir, 'barrier_mapreduce.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'values' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert 'values' in space assert space['values'] == product(list(range(20))) simple_execute()
def test_describe(): jugfile = os.path.join(_jugdir, 'write_with_meta.py') store, space = jug.jug.init(jugfile, 'testing_TO_DELETE.jugdata') simple_execute() x = space['x'] desc = describe(x) import json assert desc == json.load(open('x.meta.json')) import yaml assert desc == yaml.load(open('x.meta.yaml'))
def test_barrier(): store, space = jug.jug.init('jug/tests/jugfiles/wbarrier.py', 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/wbarrier.py', store) assert 'four' in space # This is a regression test: # a test version of jug would fail here: simple_execute()
def test_nocache(): jugfile = os.path.join(_jugdir, 'simple.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() options = default_options.copy() options.jugdir = store options.jugfile = jugfile options.verbose = 'quiet' assert status.status(options) == 8 * 4
def test_describe_load(__remove_files): jugfile = find_test_jugfile('write_with_meta.py') store, space = jug.jug.init(jugfile, 'testing_TO_DELETE.jugdata') simple_execute() x = space['x'] desc = describe(x) import json assert desc == json.load(open('x.meta.json')) import yaml assert desc == yaml.safe_load(open('x.meta.yaml'))
def test_mapreduce_barrier(): store, space = jug.jug.init('jug/tests/jugfiles/barrier_mapreduce.py', 'dict_store') assert 'values' not in space simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/barrier_mapreduce.py', store) assert 'values' in space assert space['values'] == product(list(range(20))) simple_execute()
def test_describe(): jugfile = 'jug/tests/jugfiles/write_with_meta.py' store, space = jug.jug.init(jugfile, 'testing_TO_DELETE.jugdata') simple_execute() x = space['x'] desc = describe(x) import json assert desc == json.load(open('x.meta.json')) import yaml assert desc == yaml.load(open('x.meta.yaml'))
def test_barrier(): store, space = jug.jug.init("jug/tests/jugfiles/wbarrier.py", "dict_store") assert "four" not in space simple_execute() store, space = jug.jug.init("jug/tests/jugfiles/wbarrier.py", store) assert "four" in space # This is a regression test: # a test version of jug would fail here: simple_execute()
def test_recursive(): from sys import version_info if version_info[0] == 2 and version_info[1] == 6: "We skip this test on Python 2.6" return jugfile = os.path.join(_jugdir, 'barrier_recurse.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 's2' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert 's2' in space
def test_complex(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', store) opts = Options(default_options) opts.invalid_name = space['t'].name h = space['t'].hash() assert store.can_load(h) jug.jug.invalidate(store, opts) assert not store.can_load(h)
def test_barrier(): jugfile = os.path.join(_jugdir, 'wbarrier.py') store, space = jug.jug.init(jugfile, 'dict_store') assert 'four' not in space simple_execute() store, space = jug.jug.init(jugfile, store) assert 'four' in space # This is a regression test: # a test version of jug would fail here: simple_execute()