diff --git a/README.md b/README.md index d68e9556..955844d4 100644 --- a/README.md +++ b/README.md @@ -29,23 +29,15 @@ Listening on http://localhost:8080/ Hit Ctrl-C to quit. ``` -
- -Running optuna-dashboard with Gunicorn - -optuna-dashboard uses [wsgiref](https://docs.python.org/3/library/wsgiref.html) module -which is provided as a Python standard library. But it has not been reviewed for security -issues, so not suitable for the production use. You can run optuna-dashboard with Gunicorn -more secure and/or more fast. +Note that optuna-dashboard uses [wsgiref](https://docs.python.org/3/library/wsgiref.html) module by default. +Although it requires no additional dependencies, it is NOT suitable for the production use. +You can use [Gunicorn](https://gunicorn.org/) via "--server gunicorn" option. ```console $ pip install gunicorn $ optuna-dashboard sqlite:///db.sqlite3 --server gunicorn ``` -
- -
More command line options @@ -75,7 +67,7 @@ optional arguments: Python Interface -**`run_server(storage: Union[str, BaseStorage], host: str = 'localhost', port: int = 8080) -> NoReturn`** +**`run_server(storage: Union[str, BaseStorage], host: str = 'localhost', port: int = 8080) -> None`** Start running optuna-dashboard and blocks until the server terminates. This function uses wsgiref module which is not intended for the production use. diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index cafdff30..47320fb8 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -12,7 +12,6 @@ from typing import Callable from typing import cast from typing import Dict from typing import List -from typing import NoReturn from typing import Optional from typing import TypeVar from typing import Union @@ -294,9 +293,9 @@ def get_storage(storage: Union[str, BaseStorage]) -> BaseStorage: return storage -def run_server( # type: ignore +def run_server( storage: Union[str, BaseStorage], host: str = "localhost", port: int = 8080 -) -> NoReturn: +) -> None: """Start running optuna-dashboard and blocks until the server terminates. This function uses wsgiref module which is not intended for the production use. If you want to run optuna-dashboard more secure and/or more fast, diff --git a/optuna_dashboard/_cli.py b/optuna_dashboard/_cli.py index 7812de0d..c97ca482 100644 --- a/optuna_dashboard/_cli.py +++ b/optuna_dashboard/_cli.py @@ -1,6 +1,5 @@ import argparse import os -from typing import NoReturn from bottle import Bottle from bottle import run @@ -16,7 +15,7 @@ AUTO_RELOAD = os.environ.get("OPTUNA_DASHBOARD_AUTO_RELOAD") == "1" SERVER_CHOICES = ["wsgiref", "gunicorn"] -def run_wsgiref(app: Bottle, host: str, port: int, quiet: bool) -> NoReturn: # type: ignore +def run_wsgiref(app: Bottle, host: str, port: int, quiet: bool) -> None: run( app, host=host, @@ -27,12 +26,12 @@ def run_wsgiref(app: Bottle, host: str, port: int, quiet: bool) -> NoReturn: # ) -def run_gunicorn(app: Bottle, host: str, port: int, quiet: bool) -> NoReturn: # type: ignore +def run_gunicorn(app: Bottle, host: str, port: int, quiet: bool) -> None: # See https://docs.gunicorn.org/en/latest/custom.html from gunicorn.app.base import BaseApplication - class _Application(BaseApplication): + class Application(BaseApplication): def load_config(self) -> None: self.cfg.set("bind", f"{host}:{port}") if quiet: @@ -41,10 +40,10 @@ def run_gunicorn(app: Bottle, host: str, port: int, quiet: bool) -> NoReturn: # def load(self) -> Bottle: return app - _Application().run() + Application().run() -def main() -> NoReturn: +def main() -> None: parser = argparse.ArgumentParser(description="Real-time dashboard for Optuna.") parser.add_argument("storage", help="DB URL (e.g. sqlite:///example.db)", type=str) parser.add_argument(