def test_failed_task_keep_going(): from jug.jug import execution_loop from jug.task import alltasks options = parse(['execute']) options.jugfile = find_test_jugfile('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 options.execute_target = None 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
def simple_execute(): from jug.jug import execution_loop from jug.task import alltasks from jug.options import default_options from collections import defaultdict execution_loop(alltasks, default_options, defaultdict(int), defaultdict(int))
def test_failed_task(): from jug.jug import execution_loop from jug.task import alltasks from jug.tests.jugfiles.exceptions import FailingTask options = parse(['execute']) options.jugfile = find_test_jugfile('failing.py') # keep_failed ensures errored tasks are marked as failed options.execute_keep_failed = True options.execute_target = None 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
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
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
def test_aggressive_unload(jugfile): from jug.jug import execution_loop from jug.task import alltasks options = parse(['execute']) options.aggressive_unload = True options.execute_target = None store, space = jug.jug.init(find_test_jugfile(jugfile), 'dict_store') execution_loop(alltasks, options)
def test_target_wild(): from jug.jug import execution_loop from jug.task import alltasks options = parse(['execute']) options.jugfile = find_test_jugfile('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
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
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
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
def test_cleanup_failed_only(): jugfile = os.path.join(_jugdir, 'tasklets.py') store, space = jug.jug.init(jugfile, 'dict_store') h = space['t'].hash() # With locked tasks we need to bypass execute waiting mechanisms from jug.task import alltasks from jug.jug import execution_loop opts = Options(default_options) opts.execute_nr_wait_cycles = 1 opts.execute_wait_cycle_time = 0 opts.execute_keep_failed = True execution_loop(alltasks, opts) # Fail one task manually lock = store.getlock(h) assert lock.get() assert lock.fail() assert lock.is_failed() # Keep locks should not remove failed tasks opts = Options(default_options) opts.cleanup_keep_locks = True jug.subcommands.cleanup.cleanup(store, opts) assert lock.is_locked() assert lock.is_failed() # Failed only should remove failed tasks opts = Options(default_options) opts.cleanup_failed_only = True jug.subcommands.cleanup.cleanup(store, opts) assert not lock.is_locked() assert not lock.is_failed()
def run_jugfile(jugfile): store, space = jug.jug.init(jugfile, 'dict_store') execution_loop(alltasks, options)
def simple_execute(): from jug.jug import execution_loop from jug.task import alltasks from jug.options import parse execution_loop(alltasks, parse(['execute']))
def simple_execute(): from jug.jug import execution_loop from jug.task import alltasks from jug.options import default_options execution_loop(alltasks, default_options)