コード例 #1
0
ファイル: main.py プロジェクト: indera/distributed
def processing_plot_update():
    with log_errors():
        msg = messages['processing']
        if not msg['ncores']:
            return
        data = processing_update(msg)
        x_range = processing_plot.x_range
        max_right = max(data['right'])
        min_left = min(data['left'][:-1])
        cores = max(data['ncores'])
        if min_left < x_range.start:  # not out there enough, jump ahead
            x_range.start = min_left - 2
        elif x_range.start < 2 * min_left - cores:  # way out there, walk back
            x_range.start = x_range.start * 0.95 + min_left * 0.05
        if x_range.end < max_right:
            x_range.end = max_right + 2
        elif x_range.end > 2 * max_right + cores:  # way out there, walk back
            x_range.end = x_range.end * 0.95 + max_right * 0.05

        processing_source.data.update(data)
コード例 #2
0
def test_processing_update():
    from distributed.diagnostics.scheduler import processing
    from distributed.bokeh.worker_monitor import processing_update

    class C(object):
        pass

    s = C()
    s.stacks = {"alice": ["inc", "inc", "add"], "bob": ["add", "add"]}
    s.processing = {"alice": {"inc", "add"}, "bob": {"inc"}}
    s.ready = ["a", "b", "c", "d", "e", "f", "g"]
    s.waiting = {"x": set()}
    s.who_has = {"z": set()}
    s.ncores = {"alice": 4, "bob": 4}

    msg = processing(s)

    assert msg == {
        "processing": {"alice": 2, "bob": 1},
        "stacks": {"alice": 3, "bob": 2},
        "ready": 7,
        "waiting": 1,
        "memory": 1,
        "ncores": {"alice": 4, "bob": 4},
    }

    data = processing_update(msg)
    expected = {
        "name": ["alice", "bob", "ready"],
        "processing": [2, 1, 0],
        "stacks": [3, 2, 7],
        "left": [-3, -2, -7 / 2],
        "right": [2, 1, 0],
        "top": [2, 1, 2],
        "bottom": [1, 0, 0],
        "ncores": [4, 4, 8],
        "alpha": [0.7, 0.7, 0.2],
    }

    assert data == expected
コード例 #3
0
def test_processing_update():
    from distributed.diagnostics.scheduler import processing
    from distributed.bokeh.worker_monitor import processing_update

    class C(object):
        pass

    s = C()
    s.stacks = {'alice': ['inc', 'inc', 'add'], 'bob': ['add', 'add']}
    s.processing = {'alice': {'inc', 'add'}, 'bob': {'inc'}}
    s.ready = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
    s.waiting = {'x': set()}
    s.who_has = {'z': set()}
    s.ncores = {'alice': 4, 'bob': 4}

    msg = processing(s)

    assert msg == {'processing': {'alice': 2, 'bob': 1},
                   'stacks': {'alice': 3, 'bob': 2},
                   'ready': 7,
                   'waiting': 1,
                   'memory': 1,
                   'ncores': {'alice': 4, 'bob': 4}}

    data = processing_update(msg)
    expected = {'name': ['alice', 'bob', 'ready'],
                'processing': [2, 1, 0],
                'stacks': [3, 2, 7],
                'left': [-3, -2, -7/2],
                'right': [2, 1, 0],
                'top': [2, 1, 2],
                'bottom': [1, 0, 0],
                'ncores': [4, 4, 8],
                'alpha': [0.7, 0.7, 0.2]}

    assert data == expected