diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index 12571829..b7702c35 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -377,7 +377,7 @@ def run_server( DeprecationWarning, ) artifact_store = ArtifactBackendToStore(artifact_backend) - if not is_artifact_store(artifact_store): + if artifact_store is not None and not is_artifact_store(artifact_store): artifact_store = ArtifactBackendToStore(artifact_store) app = create_app(get_storage(storage), artifact_store=artifact_store) @@ -401,7 +401,7 @@ def wsgi( DeprecationWarning, ) artifact_store = ArtifactBackendToStore(artifact_backend) - if not is_artifact_store(artifact_store): + if artifact_store is not None and not is_artifact_store(artifact_store): artifact_store = ArtifactBackendToStore(artifact_store) return create_app(get_storage(storage), artifact_store=artifact_store) diff --git a/optuna_dashboard/artifact/_backend.py b/optuna_dashboard/artifact/_backend.py index d90773d9..71ea38c7 100644 --- a/optuna_dashboard/artifact/_backend.py +++ b/optuna_dashboard/artifact/_backend.py @@ -20,6 +20,7 @@ from .._bottle_util import json_api_view from .._bottle_util import parse_data_uri from .._storage import get_trial + if TYPE_CHECKING: from typing import Any from typing import Optional @@ -136,12 +137,13 @@ def upload_artifact( mimetype: Optional[str] = None, encoding: Optional[str] = None, ) -> str: - """[Deprecated] Upload an artifact (files), which is associated with the trial. + """Upload an artifact (files), which is associated with the trial. - .. note:: + .. warning:: This function is deprecated. Please use `optuna.artifacts.upload_artifact - `_ instead. + `_ instead. Example: .. code-block:: python @@ -160,7 +162,8 @@ def upload_artifact( """ warnings.warn( "This function is deprecated. Please use optuna.artifacts.upload_artifact() instead.\n" - "https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.upload_artifact.html", + "See https://optuna.readthedocs.io/en/latest/reference/generated/" + "optuna.artifacts.upload_artifact.html", DeprecationWarning, ) diff --git a/optuna_dashboard/artifact/boto3.py b/optuna_dashboard/artifact/boto3.py index 31b6a1b5..2ef8766b 100644 --- a/optuna_dashboard/artifact/boto3.py +++ b/optuna_dashboard/artifact/boto3.py @@ -20,9 +20,11 @@ if TYPE_CHECKING: class Boto3Backend: """An artifact backend for S3. - .. note:: + .. warning:: - This class is deprecated. Please use `optuna.artifacts.Boto3ArtifactStore `_ instead.", + This class is deprecated. Please use `optuna.artifacts.Boto3ArtifactStore + `_ instead.", Example: .. code-block:: python @@ -51,7 +53,8 @@ class Boto3Backend: self._avoid_buf_copy = avoid_buf_copy warnings.warn( "Boto3Backend is deprecated. Please use optuna.artifacts.Boto3ArtifactStore instead.\n" - "https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.Boto3ArtifactStore.html", + "See https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts." + "Boto3ArtifactStore.html", DeprecationWarning, ) diff --git a/optuna_dashboard/artifact/file_system.py b/optuna_dashboard/artifact/file_system.py index 58c795e8..bf449cc6 100644 --- a/optuna_dashboard/artifact/file_system.py +++ b/optuna_dashboard/artifact/file_system.py @@ -18,7 +18,8 @@ class FileSystemBackend: .. note:: This class is deprecated. Please use `optuna.artifacts.FileSystemArtifactStore - `_ instead.", + `_ instead.", Example: .. code-block:: python @@ -39,8 +40,9 @@ class FileSystemBackend: def __init__(self, base_path: str) -> None: self._base_path = base_path warnings.warn( - "FileSystemBackend is deprecated. Please use optuna.artifacts.FileSystemArtifactStore instead.\n" - "https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.FileSystemArtifactStore.html", + "FileSystemBackend is deprecated. Please use FileSystemArtifactStore instead.\n" + "See https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts." + "FileSystemArtifactStore.html", DeprecationWarning, ) diff --git a/optuna_dashboard/artifact/protocol.py b/optuna_dashboard/artifact/protocol.py index b85fc82f..3f9ffdf2 100644 --- a/optuna_dashboard/artifact/protocol.py +++ b/optuna_dashboard/artifact/protocol.py @@ -57,17 +57,3 @@ class ArtifactBackend(Protocol): artifact_id: The identifier of the artifact to remove. """ ... - - -class ArtifactStoreWrapper: - def __init__(self, artifact_backend: ArtifactBackend) -> None: - self._backend = artifact_backend - - def open_reader(self, artifact_id: str) -> BinaryIO: - return self._backend.open(artifact_id) - - def write(self, artifact_id: str, content_body: BinaryIO) -> None: - self._backend.write(artifact_id, content_body) - - def remove(self, artifact_id: str) -> None: - self._backend.remove(artifact_id)