-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from rapidsai/branch-0.10
Forward merge v0.10 => v0.11
- Loading branch information
Showing
28 changed files
with
646 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file controls which features from the `ops-bot` repository below are enabled. | ||
# - https://github.com/rapidsai/ops-bot | ||
|
||
forward_merger: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,3 +80,5 @@ dependencies: | |
packages: | ||
- pytest | ||
- pytest-jupyter[server]>=0.6.0 | ||
- pytest-asyncio | ||
- websockets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from tornado.websocket import WebSocketHandler | ||
import tornado | ||
import json | ||
|
||
|
||
class CustomWebSocketHandler(WebSocketHandler): | ||
def open(self): | ||
self.write_message(json.dumps({"status": "connected"})) | ||
self.set_nodelay(True) | ||
# Start a periodic callback to send data every 50ms | ||
self.callback = tornado.ioloop.PeriodicCallback(self.send_data, 1000) | ||
self.callback.start() | ||
|
||
def on_message(self, message): | ||
message_data = json.loads(message) | ||
# Update the periodic callback frequency | ||
new_frequency = message_data["updateFrequency"] | ||
if hasattr(self, "callback"): | ||
self.callback.stop() | ||
self.callback = tornado.ioloop.PeriodicCallback( | ||
self.send_data, new_frequency | ||
) | ||
if not message_data["isPaused"]: | ||
self.callback.start() | ||
|
||
def on_close(self): | ||
if hasattr(self, "callback") and self.callback.is_running(): | ||
self.callback.stop() | ||
|
||
def send_data(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def pytest_configure(config): | ||
config.addinivalue_line("markers", "asyncio: mark test as asyncio") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
import pytest | ||
from unittest.mock import MagicMock, patch | ||
|
||
from jupyterlab_nvdashboard.apps.cpu import CPUResourceWebSocketHandler | ||
|
||
|
||
@pytest.fixture | ||
def mock_handler(monkeypatch): | ||
mock = MagicMock() | ||
monkeypatch.setattr( | ||
"jupyterlab_nvdashboard.apps.cpu.CustomWebSocketHandler.write_message", | ||
mock, | ||
) | ||
return mock | ||
|
||
|
||
@pytest.fixture | ||
def handler_args(): | ||
with patch("tornado.web.Application") as mock_application, patch( | ||
"tornado.httputil.HTTPServerRequest" | ||
) as mock_request: | ||
yield mock_application, mock_request | ||
|
||
|
||
def test_cpu_resource_handler(mock_handler, handler_args): | ||
handler = CPUResourceWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "time" in data | ||
assert "cpu_utilization" in data | ||
assert "memory_usage" in data | ||
assert "disk_read" in data | ||
assert "disk_write" in data | ||
assert "network_read" in data | ||
assert "network_write" in data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import json | ||
import pytest | ||
from unittest.mock import MagicMock, patch | ||
|
||
from jupyterlab_nvdashboard.apps.gpu import ( | ||
GPUUtilizationWebSocketHandler, | ||
GPUUsageWebSocketHandler, | ||
GPUResourceWebSocketHandler, | ||
NVLinkThroughputWebSocketHandler, | ||
PCIStatsWebSocketHandler, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def mock_handler(monkeypatch): | ||
mock = MagicMock() | ||
monkeypatch.setattr( | ||
"jupyterlab_nvdashboard.apps.gpu.CustomWebSocketHandler.write_message", | ||
mock, | ||
) | ||
return mock | ||
|
||
|
||
@pytest.fixture | ||
def handler_args(): | ||
with patch("tornado.web.Application") as mock_application, patch( | ||
"tornado.httputil.HTTPServerRequest" | ||
) as mock_request: | ||
yield mock_application, mock_request | ||
|
||
|
||
def test_gpu_utilization_handler(mock_handler, handler_args): | ||
handler = GPUUtilizationWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "gpu_utilization" in data | ||
|
||
|
||
def test_gpu_usage_handler(mock_handler, handler_args): | ||
handler = GPUUsageWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "memory_usage" in data | ||
assert "total_memory" in data | ||
|
||
|
||
def test_gpu_resource_handler(mock_handler, handler_args): | ||
handler = GPUResourceWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "time" in data | ||
assert "gpu_utilization_total" in data | ||
assert "gpu_memory_total" in data | ||
assert "rx_total" in data | ||
assert "tx_total" in data | ||
assert "gpu_memory_individual" in data | ||
assert "gpu_utilization_individual" in data | ||
|
||
|
||
def test_nvlink_throughput_handler(mock_handler, handler_args): | ||
handler = NVLinkThroughputWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "nvlink_rx" in data | ||
assert "nvlink_tx" in data | ||
assert "max_rxtx_bw" in data | ||
|
||
|
||
def test_pci_stats_handler(mock_handler, handler_args): | ||
handler = PCIStatsWebSocketHandler(*handler_args) | ||
handler.send_data() | ||
args, _ = mock_handler.call_args | ||
data = json.loads(args[0]) | ||
assert "pci_tx" in data | ||
assert "pci_rx" in data | ||
assert "max_rxtx_tp" in data |
Oops, something went wrong.