mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-21 13:10:53 +08:00
Merge pull request #186 from optuna/debug-mode
Disable gzip when DEBUG mode is enabled
This commit is contained in:
+2
-2
@@ -54,10 +54,10 @@ $ optuna-dashboard sqlite:///db.sqlite3
|
||||
|
||||
<summary>Environment variables for development</summary>
|
||||
|
||||
If you set `OPTUNA_DASHBOARD_AUTO_RELOAD=1`, the server will automatically restart when the source codes are changed.
|
||||
If you set `OPTUNA_DASHBOARD_DEBUG=1`, the server will automatically restart when the source codes are changed.
|
||||
|
||||
```
|
||||
$ OPTUNA_DASHBOARD_AUTO_RELOAD=1 optuna-dashboard sqlite:///db.sqlite3
|
||||
$ OPTUNA_DASHBOARD_DEBUG=1 optuna-dashboard sqlite:///db.sqlite3
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
@@ -102,7 +102,7 @@ def get_trials(
|
||||
return trials
|
||||
|
||||
|
||||
def create_app(storage: BaseStorage) -> Bottle:
|
||||
def create_app(storage: BaseStorage, debug: bool = False) -> Bottle:
|
||||
app = Bottle()
|
||||
|
||||
@app.hook("before_request")
|
||||
@@ -256,7 +256,7 @@ def create_app(storage: BaseStorage) -> Bottle:
|
||||
|
||||
@app.get("/static/<filename:path>")
|
||||
def send_static(filename: str) -> BottleViewReturn:
|
||||
if "gzip" in request.headers["Accept-Encoding"]:
|
||||
if not debug and "gzip" in request.headers["Accept-Encoding"]:
|
||||
gz_filename = filename.strip("/\\") + ".gz"
|
||||
if os.path.exists(os.path.join(STATIC_DIR, gz_filename)):
|
||||
filename = gz_filename
|
||||
|
||||
@@ -11,7 +11,7 @@ from . import __version__
|
||||
from ._app import create_app
|
||||
|
||||
|
||||
AUTO_RELOAD = os.environ.get("OPTUNA_DASHBOARD_AUTO_RELOAD") == "1"
|
||||
DEBUG = os.environ.get("OPTUNA_DASHBOARD_DEBUG") == "1"
|
||||
SERVER_CHOICES = ["wsgiref", "gunicorn"]
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ def run_wsgiref(app: Bottle, host: str, port: int, quiet: bool) -> None:
|
||||
port=port,
|
||||
server="wsgiref",
|
||||
quiet=quiet,
|
||||
reloader=AUTO_RELOAD,
|
||||
reloader=DEBUG,
|
||||
)
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ def main() -> None:
|
||||
else:
|
||||
storage = RDBStorage(args.storage)
|
||||
|
||||
app = create_app(storage)
|
||||
app = create_app(storage, debug=DEBUG)
|
||||
if args.server == "wsgiref":
|
||||
run_wsgiref(app, args.host, args.port, args.quiet)
|
||||
elif args.server == "gunicorn":
|
||||
|
||||
Reference in New Issue
Block a user