Fix lint errors

This commit is contained in:
c-bata
2023-08-04 17:53:34 +09:00
parent bdd7056394
commit 375d863959
5 changed files with 20 additions and 26 deletions
+2 -2
View File
@@ -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)
+7 -4
View File
@@ -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
<https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.upload_artifact.html>`_ instead.
<https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.
upload_artifact.html>`_ 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,
)
+6 -3
View File
@@ -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 <https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.Boto3ArtifactStore.html>`_ instead.",
This class is deprecated. Please use `optuna.artifacts.Boto3ArtifactStore
<https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.
Boto3ArtifactStore.html>`_ 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,
)
+5 -3
View File
@@ -18,7 +18,8 @@ class FileSystemBackend:
.. note::
This class is deprecated. Please use `optuna.artifacts.FileSystemArtifactStore
<https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.FileSystemArtifactStore.html>`_ instead.",
<https://optuna.readthedocs.io/en/latest/reference/generated/optuna.artifacts.
FileSystemArtifactStore.html>`_ 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,
)
-14
View File
@@ -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)