Ejemplo 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']
Ejemplo n.º 2
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']
Ejemplo n.º 3
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
Ejemplo 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
Ejemplo n.º 5
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'])}}
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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'])
        }
    }
Ejemplo n.º 11
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"])
        },
    }
Ejemplo n.º 12
0
def test_start_state_with_independent_but_runnable_tasks():
    assert start_state_from_dask({"x": (inc, 1)})["ready"] == ["x"]
Ejemplo n.º 13
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}
Ejemplo n.º 14
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"]
Ejemplo n.º 15
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}
Ejemplo n.º 16
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']
Ejemplo n.º 17
0
def test_start_state_with_independent_but_runnable_tasks():
    assert start_state_from_dask({'x': (inc, 1)})['ready'] == ['x']
Ejemplo n.º 18
0
def test_start_state_with_independent_but_runnable_tasks():
    assert start_state_from_dask({'x': (inc, 1)})['ready'] == ['x']
Ejemplo n.º 19
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}
Ejemplo n.º 20
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']