Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --warm option to panel serve #1971

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions panel/command/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from urllib.parse import urljoin

from bokeh.command.subcommands.serve import Serve as _BkServe
from bokeh.command.util import build_single_handler_applications

from ..auth import OAuthProvider
from ..config import config
Expand Down Expand Up @@ -111,6 +112,10 @@ class Serve(_BkServe):
type = int,
help = "The length of the session history to record.",
default = 0
)),
('--warm', dict(
action = 'store_true',
help = "Whether to execute scripts on startup to warm up the server."
))
)

Expand Down Expand Up @@ -143,6 +148,12 @@ def customize_kwargs(self, args, server_kwargs):
with edit_readonly(state):
state.base_url = urljoin('/', prefix)

if args.warm:
argvs = {f: args.args for f in files}
applications = build_single_handler_applications(files, argvs)
for app in applications.values():
app.create_document()

# Handle tranquilized functions in the supplied functions
if args.rest_provider in REST_PROVIDERS:
pattern = REST_PROVIDERS[args.rest_provider](files, args.rest_endpoint)
Expand Down