From 64a9b5065c8136479775249be9e45fbec3d64d76 Mon Sep 17 00:00:00 2001 From: c-bata Date: Sun, 15 Jan 2023 14:50:34 +0900 Subject: [PATCH] Add CLI option to use artifact --- README.md | 2 ++ optuna_dashboard/_cli.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66a2f433..f252e289 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ optional arguments: --host HOST hostname (default: 127.0.0.1) --server {wsgiref,gunicorn} server (default: auto) + --artifact-dir ARTIFACT_DIR + directory to store artifact files --version, -v show program's version number and exit --quiet, -q quiet ``` diff --git a/optuna_dashboard/_cli.py b/optuna_dashboard/_cli.py index 2d8cfbf1..c9f992a9 100644 --- a/optuna_dashboard/_cli.py +++ b/optuna_dashboard/_cli.py @@ -13,6 +13,7 @@ from bottle import run from optuna.storages import BaseStorage from optuna.storages import RDBStorage +from optuna_dashboard.artifact.file_system import FileSystemBackend from . import __version__ from ._app import create_app from ._app import get_storage @@ -94,13 +95,22 @@ def main() -> None: default="auto", choices=SERVER_CHOICES, ) + parser.add_argument( + "--artifact-dir", + help="directory to store artifact files", + default=None, + ) parser.add_argument("--version", "-v", action="version", version=__version__) parser.add_argument("--quiet", "-q", help="quiet", action="store_true") args = parser.parse_args() storage: BaseStorage storage = get_storage(args.storage) - app = create_app(storage, debug=DEBUG) + + artifact_backend = None + if args.artifact_dir is not None: + artifact_backend = FileSystemBackend(args.artifact_dir) + app = create_app(storage, artifact_backend=artifact_backend, debug=DEBUG) if DEBUG and isinstance(storage, RDBStorage): app = register_profiler_view(app, storage)