Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
This commit address the following, as well as rebasing off of main.

- Change `admin-path-name` to `admin-endpoint` to better align with the
  codebase.
- Create a new section in the profiling documentation to show how to use
  the new command line flag `--admin-endpoint=...`.
  • Loading branch information
ndmlny-qs committed Sep 11, 2023
1 parent 78a51be commit 44f288c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
14 changes: 14 additions & 0 deletions doc/how_to/profiling/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ This guide addresses how to enable the admin Panel to begin monitoring resource

The `/admin` panel provides an overview of the current application and provides tools for debugging and profiling. It can be enabled by passing the ``--admin`` argument to the `panel serve` command.

```bash
panel serve my-app.py --admin
```

When you have successfully enabled it you should be able to visit the `/admin` endpoint of your application, e.g. if you are serving locally on port 5006, visit `http://localhost:5006/admin`. You should now be greeted with the overview page, which provides some details about currently active sessions, running versions and resource usage (if `psutil` is installed):

<img src="../../_static/admin_overview.png" width="70%"></img>

## Changing the admin panel endpoint

You can change the endpoint that the admin page is rendered at by using the flag `--admin-endpoint="/my-new-admin-endpoint"`. This will change where the admin endpoint is in the Bokeh server, and cause a `404: Not Found` page to be shown if you navigate to the default `/admin` path discussed above. As an example, using the following command to start your Panel app

```bash
panel serve my-app.py --admin --admin-endpoint="/my-new-admin-endpoint"
```

and navigating to [http://localhost:5006/admin](http://localhost:5006/admin) will result in a 404 page, however, navigating to [http://localhost:5006/my-new-admin-endpoint](http://localhost:5006/my-new-admin-endpoint) will result in the admin panel.

## Related Resources
14 changes: 9 additions & 5 deletions panel/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ class Serve(_BkServe):
action = 'store_true',
help = "Whether to add an admin panel."
)),
('--admin-panel-name', dict(
('--admin-endpoint', dict(
metavar = "KEY=VALUE",
nargs = '+',
help = "Name to use for the admin panel.",
default = '/admin'
help = "Name to use for the admin endpoint.",
default = None
)),
('--admin-log-level', dict(
action = 'store',
Expand Down Expand Up @@ -355,8 +355,12 @@ def customize_kwargs(self, args, server_kwargs):
from ..io.admin import admin_panel
from ..io.server import per_app_patterns

# NOTE: `admin_panel_name` returns a list.
admin_path = args.admin_panel_name[0] if args.admin_panel_name else "/admin"
# NOTE: `admin_endpoint` returns a list. If the command line flag
# `--admin-endpoint` is not used, then we default to the `/admin` path.
admin_path = "/admin"
if args.admin_endpoint:
admin_path = args.admin_endpoint[0]

config._admin = True
app = Application(FunctionHandler(admin_panel))
unused_timeout = args.check_unused_sessions or 15000
Expand Down
6 changes: 3 additions & 3 deletions panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class _config(_base_config):

_admin = param.Boolean(default=False, doc="Whether the admin panel was enabled.")

_admin_panel_name = param.String(default=None, doc="Name to use for the admin panel.")
_admin_endpoint = param.String(default=None, doc="Name to use for the admin endpoint.")

_admin_log_level = param.Selector(
default='DEBUG', objects=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
Expand Down Expand Up @@ -458,8 +458,8 @@ def _doc_build(self):
return os.environ.get('PANEL_DOC_BUILD')

@property
def admin_panel_name(self):
return os.environ.get('PANEL_ADMIN_PANEL_NAME', self._admin_panel_name)
def admin_endpoint(self):
return os.environ.get('PANEL_ADMIN_ENDPOINT', self._admin_endpoint)

@property
def admin_log_level(self):
Expand Down

0 comments on commit 44f288c

Please sign in to comment.