-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41a3ed5
commit 4cb22cf
Showing
13 changed files
with
163 additions
and
34 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
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,4 @@ | ||
0.0.1 (February 15, 2022) | ||
========================= | ||
|
||
Initial release |
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,11 @@ | ||
Copyright 2021 David Brochart and the FPS contributors. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Empty file.
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,3 @@ | ||
# FPS Dashboard | ||
|
||
An [FPS](https://github.com/jupyter-server/fps) plugin to show a dashboard using Rich/Textual. |
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 @@ | ||
from fps_dashboard._version import __version__ # noqa |
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 @@ | ||
version_info = (0, 0, 1) | ||
__version__ = ".".join(map(str, version_info)) |
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,33 @@ | ||
import asyncio | ||
import atexit | ||
|
||
from .dashboard import show | ||
|
||
FPS = None | ||
|
||
|
||
def stop_fps(): | ||
FPS.terminate() | ||
|
||
|
||
atexit.register(stop_fps) | ||
|
||
|
||
async def main(): | ||
global FPS | ||
cmd = ["fps-uvicorn", "--fps.show_endpoints"] | ||
FPS = await asyncio.create_subprocess_exec( | ||
*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE | ||
) | ||
queue = asyncio.Queue() | ||
asyncio.create_task(show(queue)) | ||
while True: | ||
line = await FPS.stderr.readline() | ||
if line: | ||
await queue.put(line.decode().strip()) | ||
else: | ||
break | ||
|
||
|
||
def app(): | ||
asyncio.run(main()) |
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,10 @@ | ||
from fps.config import PluginModel | ||
from fps.hooks import register_config, register_plugin_name | ||
|
||
|
||
class DashboardConfig(PluginModel): | ||
foo: bool = False | ||
|
||
|
||
c = register_config(DashboardConfig) | ||
n = register_plugin_name("dashboard") |
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,47 @@ | ||
import json | ||
from typing import Dict | ||
|
||
from fastapi import FastAPI | ||
from fastapi.routing import APIWebSocketRoute | ||
from rich.console import Console | ||
from rich.table import Table | ||
|
||
|
||
async def show(queue): | ||
endpoint_marker = "ENDPOINT:" | ||
endpoints = [] | ||
get_endpoint = False | ||
while True: | ||
line = await queue.get() | ||
if endpoint_marker in line: | ||
get_endpoint = True | ||
elif get_endpoint: | ||
break | ||
if get_endpoint: | ||
i = line.find(endpoint_marker) + len(endpoint_marker) | ||
line = line[i:].strip() | ||
if not line: | ||
break | ||
endpoint = json.loads(line) | ||
endpoints.append(endpoint) | ||
|
||
table = Table(title="API Summary") | ||
table.add_column("Path", justify="left", style="cyan", no_wrap=True) | ||
table.add_column("Methods", justify="right", style="green") | ||
table.add_column("Plugin", style="magenta") | ||
|
||
for endpoint in endpoints: | ||
path = endpoint["path"] | ||
methods = ", ".join(endpoint["methods"]) | ||
plugin = ", ".join(endpoint["plugin"]) | ||
if "WEBSOCKET" in methods: | ||
path = f"[cyan on red]{path}[/]" | ||
table.add_row(path, methods, plugin) | ||
|
||
console = Console() | ||
with console.capture() as capture: | ||
console.print() | ||
console.print(table) | ||
|
||
str_output = capture.get() | ||
print(str_output) |
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 @@ | ||
[metadata] | ||
name = fps_dashboard | ||
version = attr: fps_dashboard._version.__version__ | ||
description = A dashboard plugin for FPS | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
license_file = LICENSE | ||
author = David Brochart | ||
author_email = [email protected] | ||
url = https://github.com/jupyter-server/fps | ||
platforms = Windows, Linux, Mac OS X | ||
keywords = server, fastapi, pluggy, plugins, fps, rich | ||
|
||
[bdist_wheel] | ||
universal = 1 | ||
|
||
[options] | ||
include_package_data = True | ||
packages = find: | ||
python_requires = >=3.7 | ||
|
||
install_requires = | ||
fps-uvicorn | ||
rich | ||
|
||
[options.entry_points] | ||
fps_config = | ||
fps_dashboard_config = fps_dashboard.config | ||
|
||
console_scripts = | ||
fps-dashboard = fps_dashboard.cli:app |
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,3 @@ | ||
import setuptools | ||
|
||
setuptools.setup() |