Exemple #1
0
def test_multibar_complete(s, a, b):
    s.update_graph(
        tasks=valmap(
            dumps_task,
            {
                "x-1": (inc, 1),
                "x-2": (inc, "x-1"),
                "x-3": (inc, "x-2"),
                "y-1": (dec, "x-3"),
                "y-2": (dec, "y-1"),
                "e": (throws, "y-2"),
                "other": (inc, 123),
            },
        ),
        keys=["e"],
        dependencies={
            "x-2": {"x-1"},
            "x-3": {"x-2"},
            "y-1": {"x-3"},
            "y-2": {"y-1"},
            "e": {"y-2"},
        },
    )

    p = MultiProgressWidget(["e"], scheduler=s.address, complete=True)
    yield p.listen()

    assert p._last_response["all"] == {"x": 3, "y": 2, "e": 1}
    assert all(b.value == 1.0 for k, b in p.bars.items() if k != "e")
    assert "3 / 3" in p.bar_texts["x"].value
    assert "2 / 2" in p.bar_texts["y"].value
def test_multi_progressbar_widget(s, a, b):
    s.update_graph(dsk={
        'x-1': (inc, 1),
        'x-2': (inc, 'x-1'),
        'x-3': (inc, 'x-2'),
        'y-1': (dec, 'x-3'),
        'y-2': (dec, 'y-1'),
        'e': (throws, 'y-2'),
        'other': (inc, 123)
    },
                   keys=['e'])

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert p.bars['x'].value == 1.0
    assert p.bars['y'].value == 1.0
    assert p.bars['e'].value == 0.0
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
    assert '0 / 1' in p.bar_texts['e'].value

    assert p.bars['x'].bar_style == 'success'
    assert p.bars['y'].bar_style == 'success'
    # assert p.bars['e'].bar_style == 'danger'

    assert p.status == 'error'
def test_multibar_complete(s, a, b):
    s.update_graph(tasks=valmap(
        dumps_task, {
            'x-1': (inc, 1),
            'x-2': (inc, 'x-1'),
            'x-3': (inc, 'x-2'),
            'y-1': (dec, 'x-3'),
            'y-2': (dec, 'y-1'),
            'e': (throws, 'y-2'),
            'other': (inc, 123)
        }),
                   keys=['e'],
                   dependencies={
                       'x-2': {'x-1'},
                       'x-3': {'x-2'},
                       'y-1': {'x-3'},
                       'y-2': {'y-1'},
                       'e': {'y-2'}
                   })

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port), complete=True)
    yield p.listen()

    assert p._last_response['all'] == {'x': 3, 'y': 2, 'e': 1}
    assert all(b.value == 1.0 for k, b in p.bars.items() if k != 'e')
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
Exemple #4
0
def test_multi_progressbar_widget_after_close(s, a, b):
    s.update_graph(
        tasks=valmap(
            dumps_task,
            {
                "x-1": (inc, 1),
                "x-2": (inc, "x-1"),
                "x-3": (inc, "x-2"),
                "y-1": (dec, "x-3"),
                "y-2": (dec, "y-1"),
                "e": (throws, "y-2"),
                "other": (inc, 123),
            },
        ),
        keys=["e"],
        dependencies={
            "x-2": {"x-1"},
            "x-3": {"x-2"},
            "y-1": {"x-3"},
            "y-2": {"y-1"},
            "e": {"y-2"},
        },
    )

    p = MultiProgressWidget(["x-1", "x-2", "x-3"], scheduler=s.address)
    yield p.listen()

    assert "x" in p.bars
Exemple #5
0
def test_multi_progressbar_widget(s, a, b):
    s.update_graph(tasks=valmap(dumps_task, {'x-1': (inc, 1),
                                             'x-2': (inc, 'x-1'),
                                             'x-3': (inc, 'x-2'),
                                             'y-1': (dec, 'x-3'),
                                             'y-2': (dec, 'y-1'),
                                             'e': (throws, 'y-2'),
                                             'other': (inc, 123)}),
                   keys=['e'],
                   dependencies={'x-2': ['x-1'], 'x-3': ['x-2'],
                                 'y-1': ['x-3'], 'y-2': ['y-1'],
                                 'e': ['y-2']})

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert p.bars['x'].value == 1.0
    assert p.bars['y'].value == 1.0
    assert p.bars['e'].value == 0.0
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
    assert '0 / 1' in p.bar_texts['e'].value

    assert p.bars['x'].bar_style == 'success'
    assert p.bars['y'].bar_style == 'success'
    # assert p.bars['e'].bar_style == 'danger'

    assert p.status == 'error'

    capacities = [int(re.search(r'\d+ / \d+', row.children[0].value)
                    .group().split(' / ')[1])
                  for row in p.bar_widgets.children]
    assert sorted(capacities, reverse=True) == capacities
def test_multi_progressbar_widget(s, a, b):
    s.update_graph(dsk={'x-1': (inc, 1),
                        'x-2': (inc, 'x-1'),
                        'x-3': (inc, 'x-2'),
                        'y-1': (dec, 'x-3'),
                        'y-2': (dec, 'y-1'),
                        'e': (throws, 'y-2'),
                        'other': (inc, 123)},
                   keys=['e'])

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert p.bars['x'].value == 1.0
    assert p.bars['y'].value == 1.0
    assert p.bars['e'].value == 0.0
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
    assert '0 / 1' in p.bar_texts['e'].value

    assert p.bars['x'].bar_style == 'success'
    assert p.bars['y'].bar_style == 'success'
    # assert p.bars['e'].bar_style == 'danger'

    assert p.status == 'error'
Exemple #7
0
def test_multi_progressbar_widget(s, a, b):
    s.update_graph(tasks=valmap(dumps_task, {'x-1': (inc, 1),
                                             'x-2': (inc, 'x-1'),
                                             'x-3': (inc, 'x-2'),
                                             'y-1': (dec, 'x-3'),
                                             'y-2': (dec, 'y-1'),
                                             'e': (throws, 'y-2'),
                                             'other': (inc, 123)}),
                   keys=['e'],
                   dependencies={'x-2': ['x-1'], 'x-3': ['x-2'],
                                 'y-1': ['x-3'], 'y-2': ['y-1'],
                                 'e': ['y-2']})

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert p.bars['x'].value == 1.0
    assert p.bars['y'].value == 1.0
    assert p.bars['e'].value == 0.0
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
    assert '0 / 1' in p.bar_texts['e'].value

    assert p.bars['x'].bar_style == 'success'
    assert p.bars['y'].bar_style == 'success'
    # assert p.bars['e'].bar_style == 'danger'

    assert p.status == 'error'

    capacities = [int(re.search(r'\d+ / \d+', row.children[0].value)
                    .group().split(' / ')[1])
                  for row in p.bar_widgets.children]
    assert sorted(capacities, reverse=True) == capacities
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=(s.ip, s.port), complete=True)
    yield p.listen()

    assert p.bars['inc'].value == 1.0
    assert p.bars['dec'].value == 1.0
    assert p.bars['throws'].value == 0.0
    assert '3 / 3' in p.bar_texts['inc'].value
    assert '2 / 2' in p.bar_texts['dec'].value
    assert '0 / 1' in p.bar_texts['throws'].value

    assert p.bars['inc'].bar_style == 'success'
    assert p.bars['dec'].bar_style == 'success'
    assert p.bars['throws'].bar_style == 'danger'

    assert p.status == 'error'
    assert 'Exception' in p.elapsed_time.value

    capacities = [
        int(
            re.search(r'\d+ / \d+',
                      row.children[0].value).group().split(' / ')[1])
        for row in p.bar_widgets.children
    ]
    assert sorted(capacities, reverse=True) == capacities
def test_multi_progressbar_widget_after_close(s, a, b):
    s.update_graph(dsk={'x-1': (inc, 1),
                        'x-2': (inc, 'x-1'),
                        'x-3': (inc, 'x-2'),
                        'y-1': (dec, 'x-3'),
                        'y-2': (dec, 'y-1'),
                        'e': (throws, 'y-2'),
                        'other': (inc, 123)},
                   keys=['e'])

    p = MultiProgressWidget(['x-1', 'x-2', 'x-3'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert 'x' in p.bars
Exemple #10
0
def test_values(client):
    L = [client.submit(inc, i) for i in range(5)]
    wait(L)
    p = MultiProgressWidget(L)
    client.sync(p.listen)
    assert set(p.bars) == {"inc"}
    assert p.status == "finished"
    assert p.comm.closed()
    assert "5 / 5" in p.bar_texts["inc"].value
    assert p.bars["inc"].value == 1.0

    x = client.submit(throws, 1)
    p = MultiProgressWidget([x])
    client.sync(p.listen)
    assert p.status == "error"
Exemple #11
0
def test_values(client):
    L = [client.submit(inc, i) for i in range(5)]
    wait(L)
    p = MultiProgressWidget(L)
    client.sync(p.listen)
    assert set(p.bars) == {'inc'}
    assert p.status == 'finished'
    assert p.comm.closed()
    assert '5 / 5' in p.bar_texts['inc'].value
    assert p.bars['inc'].value == 1.0

    x = client.submit(throws, 1)
    p = MultiProgressWidget([x])
    client.sync(p.listen)
    assert p.status == 'error'
def test_multi_progressbar_widget_after_close(s, a, b):
    s.update_graph(dsk={
        'x-1': (inc, 1),
        'x-2': (inc, 'x-1'),
        'x-3': (inc, 'x-2'),
        'y-1': (dec, 'x-3'),
        'y-2': (dec, 'y-1'),
        'e': (throws, 'y-2'),
        'other': (inc, 123)
    },
                   keys=['e'])

    p = MultiProgressWidget(['x-1', 'x-2', 'x-3'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert 'x' in p.bars
Exemple #13
0
def test_multi_progressbar_widget_after_close(s, a, b):
    s.update_graph(tasks=valmap(dumps_task, {'x-1': (inc, 1),
                                             'x-2': (inc, 'x-1'),
                                             'x-3': (inc, 'x-2'),
                                             'y-1': (dec, 'x-3'),
                                             'y-2': (dec, 'y-1'),
                                             'e': (throws, 'y-2'),
                                             'other': (inc, 123)}),
                   keys=['e'],
                   dependencies={'x-2': {'x-1'}, 'x-3': {'x-2'},
                                 'y-1': {'x-3'}, 'y-2': {'y-1'},
                                 'e': {'y-2'}})

    p = MultiProgressWidget(['x-1', 'x-2', 'x-3'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert 'x' in p.bars
def test_values(loop):
    with cluster() as (s, [a, b]):
        with Client(s['address'], loop=loop) as c:
            L = [c.submit(inc, i) for i in range(5)]
            wait(L)
            p = MultiProgressWidget(L)
            sync(loop, p.listen)
            assert set(p.bars) == {'inc'}
            assert p.status == 'finished'
            assert p.comm.closed()
            assert '5 / 5' in p.bar_texts['inc'].value
            assert p.bars['inc'].value == 1.0

            x = c.submit(throws, 1)
            p = MultiProgressWidget([x])
            sync(loop, p.listen)
            assert p.status == 'error'
Exemple #15
0
def test_values(loop):
    with cluster() as (s, [a, b]):
        with Executor(('127.0.0.1', s['port']), loop=loop) as e:
            L = [e.submit(inc, i) for i in range(5)]
            wait(L)
            p = MultiProgressWidget(L)
            sync(loop, p.listen)
            assert set(p.bars) == {'inc'}
            assert p.status == 'finished'
            assert p.stream.closed()
            assert '5 / 5' in p.bar_texts['inc'].value
            assert p.bars['inc'].value == 1.0

            x = e.submit(throws, 1)
            p = MultiProgressWidget([x])
            sync(loop, p.listen)
            assert p.status == 'error'
Exemple #16
0
def test_multi_progressbar_widget_after_close(s, a, b):
    s.update_graph(tasks=valmap(dumps_task, {'x-1': (inc, 1),
                                             'x-2': (inc, 'x-1'),
                                             'x-3': (inc, 'x-2'),
                                             'y-1': (dec, 'x-3'),
                                             'y-2': (dec, 'y-1'),
                                             'e': (throws, 'y-2'),
                                             'other': (inc, 123)}),
                   keys=['e'],
                   dependencies={'x-2': {'x-1'}, 'x-3': {'x-2'},
                                 'y-1': {'x-3'}, 'y-2': {'y-1'},
                                 'e': {'y-2'}})

    p = MultiProgressWidget(['x-1', 'x-2', 'x-3'], scheduler=(s.ip, s.port))
    yield p.listen()

    assert 'x' in p.bars
def test_multibar_complete(s, a, b):
    s.update_graph(dsk={'x-1': (inc, 1),
                        'x-2': (inc, 'x-1'),
                        'x-3': (inc, 'x-2'),
                        'y-1': (dec, 'x-3'),
                        'y-2': (dec, 'y-1'),
                        'e': (throws, 'y-2'),
                        'other': (inc, 123)},
                   keys=['e'])

    p = MultiProgressWidget(['e'], scheduler=(s.ip, s.port), complete=True)
    yield p.listen()

    assert p._last_response['all'] == {'x': 3, 'y': 2, 'e': 1}
    assert all(b.value == 1.0 for k, b in p.bars.items() if k != 'e')
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
Exemple #18
0
def test_multibar_complete(s, a, b):
    s.update_graph(tasks=valmap(dumps_task, {'x-1': (inc, 1),
                                             'x-2': (inc, 'x-1'),
                                             'x-3': (inc, 'x-2'),
                                             'y-1': (dec, 'x-3'),
                                             'y-2': (dec, 'y-1'),
                                             'e': (throws, 'y-2'),
                                             'other': (inc, 123)}),
                   keys=['e'],
                   dependencies={'x-2': {'x-1'}, 'x-3': {'x-2'},
                                 'y-1': {'x-3'}, 'y-2': {'y-1'},
                                 'e': {'y-2'}})

    p = MultiProgressWidget(['e'], scheduler=s.address, complete=True)
    yield p.listen()

    assert p._last_response['all'] == {'x': 3, 'y': 2, 'e': 1}
    assert all(b.value == 1.0 for k, b in p.bars.items() if k != 'e')
    assert '3 / 3' in p.bar_texts['x'].value
    assert '2 / 2' in p.bar_texts['y'].value
Exemple #19
0
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=s.address, complete=True)
    yield p.listen()

    assert p.bars["inc"].value == 1.0
    assert p.bars["dec"].value == 1.0
    assert p.bars["throws"].value == 0.0
    assert "3 / 3" in p.bar_texts["inc"].value
    assert "2 / 2" in p.bar_texts["dec"].value
    assert "0 / 1" in p.bar_texts["throws"].value

    assert p.bars["inc"].bar_style == "success"
    assert p.bars["dec"].bar_style == "success"
    assert p.bars["throws"].bar_style == "danger"

    assert p.status == "error"
    assert "Exception" in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value

    capacities = [
        int(
            re.search(r"\d+ / \d+",
                      row.children[0].value).group().split(" / ")[1])
        for row in p.bar_widgets.children
    ]
    assert sorted(capacities, reverse=True) == capacities
Exemple #20
0
def test_multi_progressbar_widget(c, s, a, b):
    x1 = c.submit(inc, 1)
    x2 = c.submit(inc, x1)
    x3 = c.submit(inc, x2)
    y1 = c.submit(dec, x3)
    y2 = c.submit(dec, y1)
    e = c.submit(throws, y2)
    other = c.submit(inc, 123)
    yield wait([other, e])

    p = MultiProgressWidget([e.key], scheduler=s.address, complete=True)
    yield p.listen()

    assert p.bars['inc'].value == 1.0
    assert p.bars['dec'].value == 1.0
    assert p.bars['throws'].value == 0.0
    assert '3 / 3' in p.bar_texts['inc'].value
    assert '2 / 2' in p.bar_texts['dec'].value
    assert '0 / 1' in p.bar_texts['throws'].value

    assert p.bars['inc'].bar_style == 'success'
    assert p.bars['dec'].bar_style == 'success'
    assert p.bars['throws'].bar_style == 'danger'

    assert p.status == 'error'
    assert 'Exception' in p.elapsed_time.value

    try:
        throws(1)
    except Exception as e:
        assert repr(e) in p.elapsed_time.value

    capacities = [int(re.search(r'\d+ / \d+', row.children[0].value)
                      .group().split(' / ')[1])
                  for row in p.bar_widgets.children]
    assert sorted(capacities, reverse=True) == capacities