Ejemplo n.º 1
0
def test_resource_monitor_plot(s, a, b):
    while any('last-seen' not in v for v in s.host_info.values()):
        yield gen.sleep(0.01)

    times_buffer = [1000, 1001, 1003]
    workers_buffer = [{},
                      {'10.10.20.86': {'cpu': 15.9, 'memory-percent': 63.0}},
                      {'10.10.20.86': {'cpu': 14.9, 'memory-percent': 64.0,
                                       'network-send': 2**16,
                                       'network-recv': 2**15},
                       '10.10.20.87': {'cpu': 13.9, 'memory-percent': 64.0,
                                       'network-send': 2**17,
                                       'network-recv': 2**16}}]

    source, _, _, _ = resource_profile_plot()
    resource_profile_update(source, workers_buffer, times_buffer)

    assert source.data['workers'] == ['10.10.20.86', '10.10.20.87']
    assert len(source.data['cpu']) == 2
    assert source.data['cpu'][0] == ['null', 15.9, 14.9]
    assert source.data['cpu'][1] == ['null', 'null', 13.9]

    assert source.data['times'][0] == ['null', 1001000, 1003000]
    assert source.data['times'][1] == ['null','null', 1003000]
    assert len(source.data['times']) == 2
    assert len(source.data['memory-percent']) == 2

    assert len(source.data['network-send']) == 2
    assert source.data['network-send'][1] == ['null', 'null', 2**17]
    assert len(source.data['network-recv']) == 2
    assert source.data['network-recv'][1] == ['null', 'null', 2**16]
Ejemplo n.º 2
0
def test_resource_monitor_plot(s, a, b):
    while any('last-seen' not in v for v in s.host_info.values()):
        yield gen.sleep(0.01)

    times_buffer = [1000, 1001, 1003]
    workers_buffer = [{},
                      {'10.10.20.86': {'cpu': 15.9, 'memory-percent': 63.0}},
                      {'10.10.20.86': {'cpu': 14.9, 'memory-percent': 64.0,
                                       'network-send': 2**16,
                                       'network-recv': 2**15},
                       '10.10.20.87': {'cpu': 13.9, 'memory-percent': 64.0,
                                       'network-send': 2**17,
                                       'network-recv': 2**16}}]

    source, plot = resource_profile_plot()
    resource_profile_update(source, workers_buffer, times_buffer)

    assert source.data['workers'] == ['10.10.20.86', '10.10.20.87']
    assert len(source.data['cpu']) == 2
    assert source.data['cpu'][0] == ['null', 15.9, 14.9]
    assert source.data['cpu'][1] == ['null', 'null', 13.9]

    assert source.data['times'][0] == ['null', 1001000, 1003000]
    assert source.data['times'][1] == ['null','null', 1003000]
    assert len(source.data['times']) == 2
    assert len(source.data['memory-percent']) == 2

    assert len(source.data['network-send']) == 2
    assert source.data['network-send'][1] == ['null', 'null', 2**17]
    assert len(source.data['network-recv']) == 2
    assert source.data['network-recv'][1] == ['null', 'null', 2**16]
Ejemplo n.º 3
0
def test_resource_monitor_plot(s, a, b):
    while any("last-seen" not in v for v in s.host_info.values()):
        yield gen.sleep(0.01)

    times_buffer = [1000, 1001, 1003]
    workers_buffer = [
        {},
        {"10.10.20.86": {"cpu": 15.9, "memory_percent": 63.0}},
        {
            "10.10.20.86": {"cpu": 14.9, "memory_percent": 64.0, "network-send": 2 ** 16, "network-recv": 2 ** 15},
            "10.10.20.87": {"cpu": 13.9, "memory_percent": 64.0, "network-send": 2 ** 17, "network-recv": 2 ** 16},
        },
    ]

    source, _, _, _ = resource_profile_plot()
    resource_profile_update(source, workers_buffer, times_buffer)

    assert source.data["workers"] == ["10.10.20.86", "10.10.20.87"]
    assert len(source.data["cpu"]) == 2
    assert source.data["cpu"][0] == ["null", 15.9, 14.9]
    assert source.data["cpu"][1] == ["null", "null", 13.9]

    assert source.data["times"][0] == ["null", 1001000, 1003000]
    assert source.data["times"][1] == ["null", "null", 1003000]
    assert len(source.data["times"]) == 2
    assert len(source.data["memory_percent"]) == 2

    assert len(source.data["network-send"]) == 2
    assert source.data["network-send"][1] == ["null", "null", 2 ** 17]
    assert len(source.data["network-recv"]) == 2
    assert source.data["network-recv"][1] == ["null", "null", 2 ** 16]
Ejemplo n.º 4
0
from distributed.bokeh.status_monitor import (progress_plot, task_stream_plot,
        nbytes_plot)
from distributed.bokeh.worker_monitor import resource_profile_plot
from distributed.diagnostics.progress_stream import progress_quads, nbytes_bar
from distributed.utils import log_errors
import distributed.bokeh

SIZING_MODE = 'scale_width'
WIDTH = 600

messages = distributed.bokeh.messages  # global message store
doc = curdoc()


resource_index = [0]
resource_source, resource_plot, network_plot, combo_toolbar = resource_profile_plot(sizing_mode=SIZING_MODE, width=WIDTH, height=80)
def resource_update():
    with log_errors():
        index = messages['workers']['index']
        data = messages['workers']['plot-data']

        if not index or index[-1] == resource_index[0]:
            return

        if resource_index == [0]:
            data = valmap(list, data)

        ind = bisect(index, resource_index[0])
        indexes = list(range(ind, len(index)))
        data = {k: [v[i] for i in indexes] for k, v in data.items()}
        resource_index[0] = index[-1]
Ejemplo n.º 5
0
task_source, task_table = task_table_plot(width=table_width)


def task_update():
    with log_errors():
        try:
            msg = messages['tasks']['deque'][-1]
        except IndexError:
            return
        task_table_update(task_source, msg)


doc.add_periodic_callback(task_update, messages['tasks']['interval'])

resource_source, resource_plot = resource_profile_plot(height=int(width / 3),
                                                       width=width)
resource_plot.min_border_top -= 40
resource_plot.title = None
resource_plot.min_border_bottom -= 40
resource_plot.plot_height -= 80
resource_plot.logo = None
# resource_plot.toolbar_location = None
resource_plot.xaxis.axis_label = None
resource_index = [0]


def resource_update():
    with log_errors():
        index = messages['workers']['index']
        data = messages['workers']['plot-data']
Ejemplo n.º 6
0
        worker_table_update(worker_source, msg)
doc.add_periodic_callback(worker_update, messages['workers']['interval'])


task_source, task_table = task_table_plot(width=table_width)
def task_update():
    with log_errors():
        try:
            msg = messages['tasks']['deque'][-1]
        except IndexError:
            return
        task_table_update(task_source, msg)
doc.add_periodic_callback(task_update, messages['tasks']['interval'])


resource_source, resource_plot = resource_profile_plot(height=int(width/3), width=width)
resource_plot.min_border_top -= 40
resource_plot.title = None
resource_plot.min_border_bottom -= 40
resource_plot.plot_height -= 80
resource_plot.logo = None
# resource_plot.toolbar_location = None
resource_plot.xaxis.axis_label = None
resource_index = [0]


def resource_update():
    with log_errors():
        index = messages['workers']['index']
        data = messages['workers']['plot-data']
Ejemplo n.º 7
0
doc.add_periodic_callback(worker_update, messages['workers']['interval'])


task_source, task_table = task_table_plot()
def task_update():
    with log_errors():
        try:
            msg = messages['tasks']['deque'][-1]
        except IndexError:
            return
        task_table_update(task_source, msg)
doc.add_periodic_callback(task_update, messages['tasks']['interval'])


resource_index = [0]
resource_source, resource_plot, network_plot, combo_toolbar = resource_profile_plot(sizing_mode=SIZING_MODE)
def resource_update():
    with log_errors():
        index = messages['workers']['index']
        data = messages['workers']['plot-data']

        if not index or index[-1] == resource_index[0]:
            return

        if resource_index == [0]:
            data = valmap(list, data)

        ind = bisect(index, resource_index[0])
        indexes = list(range(ind, len(index)))
        data = {k: [v[i] for i in indexes] for k, v in data.items()}
        resource_index[0] = index[-1]