Esempio n. 1
0
def test_order_of_startstate():
    dsk = {'a': 1, 'b': (inc, 'a'), 'c': (inc, 'b'),
           'x': 1, 'y': (inc, 'x')}
    result = start_state_from_dask(dsk)

    assert result['ready'] == ['y', 'b']

    dsk = {'x': 1, 'y': (inc, 'x'), 'z': (inc, 'y'),
           'a': 1, 'b': (inc, 'a')}
    result = start_state_from_dask(dsk)

    assert result['ready'] == ['b', 'y']
Esempio n. 2
0
def test_finish_task():
    dsk = {'x': 1, 'y': 2, 'z': (inc, 'x'), 'w': (add, 'z', 'y')}
    sortkey = order(dsk).get
    state = start_state_from_dask(dsk)
    state['ready'].remove('z')
    state['running'] = set(['z', 'other-task'])
    task = 'z'
    result = 2

    state['cache']['z'] = result
    finish_task(dsk, task, state, set(), sortkey)

    assert state == {'cache': {'y': 2, 'z': 2},
                     'dependencies': {'w': set(['y', 'z']),
                                      'x': set([]),
                                      'y': set([]),
                                      'z': set(['x'])},
                     'finished': set(['z']),
                     'released': set(['x']),
                     'running': set(['other-task']),
                     'dependents': {'w': set([]),
                                    'x': set(['z']),
                                    'y': set(['w']),
                                    'z': set(['w'])},
                     'ready': ['w'],
                     'waiting': {},
                     'waiting_data': {'y': set(['w']),
                                      'z': set(['w'])}}
Esempio n. 3
0
def test_start_state_with_tasks_no_deps():
    dsk = {'a': [1, (inc, 2)],
           'b': [1, 2, 3, 4],
           'c': (inc, 3)}
    state = start_state_from_dask(dsk)
    assert list(state['cache'].keys()) == ['b']
    assert 'a' in state['ready'] and 'c' in state['ready']
    deps = dict((k, set()) for k in 'abc')
    assert state['dependencies'] == deps
    assert state['dependents'] == deps
Esempio n. 4
0
def test_start_state():
    dsk = {'x': 1, 'y': 2, 'z': (inc, 'x'), 'w': (add, 'z', 'y')}
    result = start_state_from_dask(dsk)

    expected = {'cache': {'x': 1, 'y': 2},
                'dependencies': {'w': set(['y', 'z']),
                                 'x': set([]),
                                 'y': set([]),
                                 'z': set(['x'])},
                'dependents': {'w': set([]),
                               'x': set(['z']),
                               'y': set(['w']),
                               'z': set(['w'])},
                'finished': set([]),
                'released': set([]),
                'running': set([]),
                'ready': ['z'],
                'waiting': {'w': set(['z'])},
                'waiting_data': {'x': set(['z']),
                                 'y': set(['w']),
                                 'z': set(['w'])}}
    assert result == expected
Esempio n. 5
0
def test_start_state_with_independent_but_runnable_tasks():
    assert start_state_from_dask({'x': (inc, 1)})['ready'] == ['x']
Esempio n. 6
0
def test_start_state_with_redirects():
    dsk = {'x': 1, 'y': 'x', 'z': (inc, 'y')}
    result = start_state_from_dask(dsk)
    assert result['cache'] == {'x': 1}
Esempio n. 7
0
def test_start_state_looks_at_cache():
    dsk = {'b': (inc, 'a')}
    cache = {'a': 1}
    result = start_state_from_dask(dsk, cache)
    assert result['dependencies']['b'] == set(['a'])
    assert result['ready'] == ['b']