Esempio n. 1
0
def test_barrier_once():
    import sys
    options = default_options.copy()
    options.jugdir = 'dict_store'
    options.jugfile = 'jug/tests/jugfiles/wbarrier.py'
    jug.jug.execute(options)
    assert 'four' in dir(sys.modules['wbarrier'])
Esempio n. 2
0
def test_failed_task():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.tests.jugfiles.exceptions import FailingTask
    options = default_options.copy()
    options.jugfile = os.path.join(_jugdir, 'failing.py')
    # keep_failed ensures errored tasks are marked as failed
    options.execute_keep_failed = True

    store, space = jug.jug.init(options.jugfile, 'dict_store')
    # the failing.py jugfile has a total of 20 reachable tasks
    assert len(alltasks) == 20
    # Keep a copy of all tasks to check for failed tasks later
    alltasks_copy = alltasks[:]

    try:
        execution_loop(alltasks, options)
    except FailingTask:  # Using a custom exception to make sure we don't silence any errors
        pass

    # The third task fails so we get 2 results and 1 failed lock
    # NOTE: This might be incorrect if order of execution is not guaranteed
    assert len(store.store) == 3
    # 10 tasks could be run and were taken. Only the 10 waiting remain
    assert len(alltasks) == 10
    assert len([x for x in alltasks_copy if x.is_failed()]) == 1
Esempio n. 3
0
def test_barrier_once():
    import sys
    options = default_options.copy()
    options.jugdir = 'dict_store'
    options.jugfile = 'jug/tests/jugfiles/wbarrier.py'
    jug.jug.execute(options)
    assert 'four' in dir(sys.modules['wbarrier'])
Esempio n. 4
0
def test_barrier_once():
    import sys
    options = default_options.copy()
    options.jugdir = 'dict_store'
    options.jugfile = os.path.join(_jugdir, 'wbarrier.py')
    jug.jug.execute(options)
    assert 'four' in dir(sys.modules['wbarrier'])
Esempio n. 5
0
def test_failed_task_keep_going():
    from jug.jug import execution_loop
    from jug.task import alltasks
    options = default_options.copy()
    options.jugfile = os.path.join(_jugdir, 'failing.py')
    # these 3 silence errors during execution and ensure jug isn't kept waiting
    options.execute_keep_going = True
    options.execute_nr_wait_cycles = 1
    options.execute_wait_cycle_time = 0
    # keep_failed ensures errored tasks are marked as failed
    options.execute_keep_failed = True

    store, space = jug.jug.init(options.jugfile, 'dict_store')
    # the failing.py jugfile has a total of 20 reachable tasks
    assert len(alltasks) == 20
    # Keep a copy of all tasks to check for failed tasks later
    alltasks_copy = alltasks[:]

    execution_loop(alltasks, options)

    # 14 results + 3 failures
    assert len(store.store) == 17
    # 3 tasks should remain in waiting state due to 3 failures upstream
    assert len(alltasks) == 3
    assert len([x for x in alltasks_copy if x.is_failed()]) == 3
Esempio n. 6
0
def test_barrier_once():
    import sys
    options = default_options.copy()
    options.jugdir = 'dict_store'
    options.jugfile = os.path.join(_jugdir, 'wbarrier.py')
    jug.subcommands.execute.execute(options)
    assert 'four' in dir(sys.modules['wbarrier'])
Esempio n. 7
0
def test_barrier_once():
    import sys

    options = default_options.copy()
    options.jugdir = "dict_store"
    options.jugfile = "jug/tests/jugfiles/wbarrier.py"
    jug.jug.execute(options)
    assert "four" in dir(sys.modules["wbarrier"])
Esempio n. 8
0
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
Esempio n. 9
0
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
Esempio n. 10
0
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
Esempio n. 11
0
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
Esempio n. 12
0
def test_cache_block_status():
    jugfile = os.path.join(_jugdir, 'block_access.py')

    options = default_options.copy()
    options.jugdir = 'dict_store'
    options.jugfile = jugfile
    options.verbose = 'quiet'
    options.status_cache = True
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
Esempio n. 13
0
def test_cache_bvalue():
    store, space = jug.jug.init('jug/tests/jugfiles/bvalue.py', 'dict_store')

    options = default_options.copy()
    options.jugdir = store
    options.jugfile = 'jug/tests/jugfiles/bvalue.py'
    options.verbose = 'quiet'
    options.status_mode = 'cached'
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
    simple_execute()
    assert status.status(options) == 1
Esempio n. 14
0
def test_debug():
    from jug.options import default_options
    options = default_options.copy()
    options.debug = True

    store, space = jug.jug.init('jug/tests/jugfiles/compound.py', 'dict_store')
    simple_execute(options = options)

    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
Esempio n. 15
0
def test_target_wild():
    from jug.jug import execution_loop
    from jug.task import alltasks
    options = default_options.copy()
    options.jugfile = os.path.join(_jugdir, 'simple_multiple.py')
    # Test if restricting to this target we skip the other tasks
    options.execute_target = "simple_multiple.sum_"

    store, space = jug.jug.init(options.jugfile, 'dict_store')
    execution_loop(alltasks, options)

    assert len(store.store) < len(alltasks)
    assert len(store.store) == 16
Esempio n. 16
0
def test_target_wild():
    from jug.jug import execution_loop
    from jug.task import alltasks
    options = default_options.copy()
    options.jugfile = os.path.join(_jugdir, 'simple_multiple.py')
    # Test if restricting to this target we skip the other tasks
    options.execute_target = "simple_multiple.sum_"

    store, space = jug.jug.init(options.jugfile, 'dict_store')
    execution_loop(alltasks, options)

    assert len(store.store) < len(alltasks)
    assert len(store.store) == 16
Esempio n. 17
0
def test_cache_bvalue():
    store, space = jug.jug.init('jug/tests/jugfiles/bvalue.py', 'dict_store')

    options = default_options.copy()
    options.jugdir = store
    options.jugfile = 'jug/tests/jugfiles/bvalue.py'
    options.verbose = 'quiet'
    options.status_mode = 'cached'
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
    simple_execute()
    assert status.status(options) == 1
Esempio n. 18
0
def test_aggressive_unload():
    from jug.options import default_options
    options = default_options.copy()
    options.aggressive_unload = True

    @task_reset
    def run_jugfile(jugfile):
        store, space = jug.jug.init(jugfile, 'dict_store')
        simple_execute(options=options)
    yield run_jugfile, 'jug/tests/jugfiles/tasklet_simple.py'
    yield run_jugfile, 'jug/tests/jugfiles/tasklets.py'
    yield run_jugfile, 'jug/tests/jugfiles/barrier_mapreduce.py'
    yield run_jugfile, 'jug/tests/jugfiles/compound_nonsimple.py'
    yield run_jugfile, 'jug/tests/jugfiles/slice_task.py'
Esempio n. 19
0
def test_cache_bvalue():
    jugfile = os.path.join(_jugdir, 'bvalue.py')
    store, space = jug.jug.init(jugfile, 'dict_store')

    options = default_options.copy()
    options.jugdir = store
    options.jugfile = jugfile
    options.verbose = 'quiet'
    options.status_cache = True
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
    simple_execute()
    assert status.status(options) == 1
Esempio n. 20
0
def test_debug():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.debug = True

    store, space = jug.jug.init('jug/tests/jugfiles/compound.py', 'dict_store')
    execution_loop(alltasks, options)
    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
Esempio n. 21
0
def test_debug():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.debug = True

    store, space = jug.jug.init('jug/tests/jugfiles/compound.py', 'dict_store')
    execution_loop(alltasks, options)
    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
Esempio n. 22
0
def test_cache_bvalue():
    jugfile = os.path.join(_jugdir, 'bvalue.py')
    store, space = jug.jug.init(jugfile, 'dict_store')

    options = default_options.copy()
    options.jugdir = store
    options.jugfile = jugfile
    options.verbose = 'quiet'
    options.status_cache = True
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
    simple_execute()
    assert status.status(options) == 1
Esempio n. 23
0
def test_aggressive_unload():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.aggressive_unload = True
    @task_reset
    def run_jugfile(jugfile):
        store, space = jug.jug.init(jugfile, 'dict_store')
        execution_loop(alltasks, options)
    yield run_jugfile, os.path.join(_jugdir, 'tasklet_simple.py')
    yield run_jugfile, os.path.join(_jugdir, 'tasklets.py')
    yield run_jugfile, os.path.join(_jugdir, 'barrier_mapreduce.py')
    yield run_jugfile, os.path.join(_jugdir, 'compound_nonsimple.py')
    yield run_jugfile, os.path.join(_jugdir, 'slice_task.py')
Esempio n. 24
0
def test_aggressive_unload():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.aggressive_unload = True
    @task_reset
    def run_jugfile(jugfile):
        store, space = jug.jug.init(jugfile, 'dict_store')
        execution_loop(alltasks, options)
    yield run_jugfile, os.path.join(_jugdir, 'tasklet_simple.py')
    yield run_jugfile, os.path.join(_jugdir, 'tasklets.py')
    yield run_jugfile, os.path.join(_jugdir, 'barrier_mapreduce.py')
    yield run_jugfile, os.path.join(_jugdir, 'compound_nonsimple.py')
    yield run_jugfile, os.path.join(_jugdir, 'slice_task.py')
Esempio n. 25
0
def test_debug():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.debug = True
    jugfile = os.path.join(_jugdir, 'compound.py')

    store, space = jug.jug.init(jugfile, 'dict_store')
    execution_loop(alltasks, options)
    assert 'sixteen' in space
    assert space['sixteen'].result == 16
    store, space = jug.jug.init(jugfile, store)
    assert 'sixteen' in space
    assert space['sixteen'].result == 16
Esempio n. 26
0
def test_cache():
    store, _ = jug.jug.init('jug/tests/jugfiles/simple.py', 'dict_store')
    while jug.task.alltasks:
        jug.task.alltasks.pop()

    options = default_options.copy()
    options.jugdir = store
    options.jugfile = 'jug/tests/jugfiles/simple.py'
    options.verbose = 'quiet'
    options.status_mode = 'cached'
    options.status_cache_file = ':memory:'

    assert status.status(options) == 0
    simple_execute()
    assert status.status(options) == 8 * 4
Esempio n. 27
0
def test_debug():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    options = default_options.copy()
    options.debug = True
    jugfile = os.path.join(_jugdir, 'compound.py')

    store, space = jug.jug.init(jugfile, 'dict_store')
    execution_loop(alltasks, options)
    assert 'sixteen' in space
    assert space['sixteen'].result == 16
    store, space = jug.jug.init(jugfile, store)
    assert 'sixteen' in space
    assert space['sixteen'].result == 16
Esempio n. 28
0
def test_aggressive_unload():
    from jug.jug import execution_loop
    from jug.task import alltasks
    from jug.options import default_options
    from collections import defaultdict
    options = default_options.copy()
    options.aggressive_unload = True

    @task_reset
    def run_jugfile(jugfile):
        store, space = jug.jug.init(jugfile, 'dict_store')
        execution_loop(alltasks, options, defaultdict(int), defaultdict(int))

    yield run_jugfile, 'jug/tests/jugfiles/tasklet_simple.py'
    yield run_jugfile, 'jug/tests/jugfiles/tasklets.py'
    yield run_jugfile, 'jug/tests/jugfiles/barrier_mapreduce.py'
    yield run_jugfile, 'jug/tests/jugfiles/compound_nonsimple.py'
    yield run_jugfile, 'jug/tests/jugfiles/slice_task.py'