mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Fix tests
This commit is contained in:
@@ -12,17 +12,22 @@ from bottle import Bottle
|
||||
from bottle import run
|
||||
from optuna.storages import BaseStorage
|
||||
from optuna.storages import RDBStorage
|
||||
from optuna.version import __version__ as optuna_ver
|
||||
from packaging import version
|
||||
|
||||
from . import __version__
|
||||
from ._app import create_app
|
||||
from ._sql_profiler import register_profiler_view
|
||||
from ._storage_url import get_storage
|
||||
from .artifact._backend_to_store import ArtifactBackendToStore
|
||||
from .artifact.file_system import FileSystemBackend
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Literal
|
||||
|
||||
from optuna.artifacts._protocol import ArtifactStore
|
||||
|
||||
|
||||
DEBUG = os.environ.get("OPTUNA_DASHBOARD_DEBUG") == "1"
|
||||
SERVER_CHOICES = ["auto", "wsgiref", "gunicorn"]
|
||||
@@ -113,10 +118,17 @@ def main() -> None:
|
||||
storage: BaseStorage
|
||||
storage = get_storage(args.storage, storage_class=args.storage_class)
|
||||
|
||||
artifact_backend = None
|
||||
if args.artifact_dir is not None:
|
||||
artifact_store: ArtifactStore | None
|
||||
if args.artifact_dir is None:
|
||||
artifact_store = None
|
||||
elif version.parse(optuna_ver) >= version.Version("3.3.0"):
|
||||
from optuna.artifacts import FileSystemArtifactStore
|
||||
|
||||
artifact_store = FileSystemArtifactStore(args.artifact_dir)
|
||||
else:
|
||||
artifact_backend = FileSystemBackend(args.artifact_dir)
|
||||
app = create_app(storage, artifact_backend=artifact_backend, debug=DEBUG)
|
||||
artifact_store = ArtifactBackendToStore(artifact_backend)
|
||||
app = create_app(storage, artifact_store=artifact_store, debug=DEBUG)
|
||||
|
||||
if DEBUG and isinstance(storage, RDBStorage):
|
||||
app = register_profiler_view(app, storage)
|
||||
|
||||
@@ -9,8 +9,8 @@ from packaging import version
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.skipIf(
|
||||
version.parse(optuna_ver) < version.Version("3.3.0.dev"),
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna_ver) < version.Version("3.3.0"),
|
||||
"Artifact is not implemented yet in Optuna",
|
||||
)
|
||||
def test_list_optuna_artifacts() -> None:
|
||||
@@ -39,4 +39,4 @@ def test_list_optuna_artifacts() -> None:
|
||||
|
||||
artifact_id = artifact_meta_list[0]["artifact_id"]
|
||||
with artifact_store.open_reader(artifact_id) as reader:
|
||||
assert reader.read() == dummy_content
|
||||
assert reader.read() == dummy_content
|
||||
|
||||
Reference in New Issue
Block a user