mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Skip unit test with optuna version
This commit is contained in:
@@ -4,6 +4,13 @@ import tempfile
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import optuna
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
|
||||
if version.parse(optuna.__version__) < version.parse("3.3.0"):
|
||||
pytest.skip("optuna.artiracts module is introduced at v3.3.0", allow_module_level=True)
|
||||
|
||||
from optuna.artifacts import FileSystemArtifactStore
|
||||
from optuna.artifacts import upload_artifact
|
||||
from optuna.storages import BaseStorage
|
||||
@@ -12,7 +19,6 @@ from optuna_dashboard.artifact import _backend
|
||||
from optuna_dashboard.artifact import upload_artifact as dashboard_upload_artifact
|
||||
from optuna_dashboard.artifact._backend_to_store import to_artifact_store
|
||||
from optuna_dashboard.artifact.file_system import FileSystemBackend
|
||||
import pytest
|
||||
|
||||
from ..wsgi_client import send_request
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from optuna.distributions import IntDistribution
|
||||
from optuna.samplers import BaseSampler
|
||||
from optuna.trial import TrialState
|
||||
from optuna_dashboard.preferential import create_study
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -27,7 +28,9 @@ parametrize_sampler = pytest.mark.parametrize(
|
||||
pytest.param(
|
||||
PreferentialGPSampler,
|
||||
marks=pytest.mark.skipif(
|
||||
sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support"
|
||||
sys.version_info < (3, 8)
|
||||
or version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="BoTorch dropped Python3.7 support",
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Callable
|
||||
from unittest.mock import patch
|
||||
import uuid
|
||||
|
||||
import optuna
|
||||
from optuna import copy_study
|
||||
from optuna import create_trial
|
||||
from optuna import delete_study
|
||||
@@ -17,12 +18,16 @@ from optuna.exceptions import DuplicatedStudyError
|
||||
from optuna.trial import TrialState
|
||||
from optuna_dashboard.preferential import create_study
|
||||
from optuna_dashboard.preferential import load_study
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
from ..storage_supplier import parametrize_storages
|
||||
from ..storage_supplier import StorageSupplier
|
||||
|
||||
|
||||
if version.parse(optuna.__version__) < version.parse("3.4.0"):
|
||||
pytest.skip("Preferential optimization is introduced at v3.4.0", allow_module_level=True)
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
pytest.skip("BoTorch dropped Python3.7 support", allow_module_level=True)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ from optuna_dashboard._preferential_history import remove_history
|
||||
from optuna_dashboard._preferential_history import report_history
|
||||
from optuna_dashboard._serializer import serialize_preference_history
|
||||
from optuna_dashboard.preferential import create_study
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
from .wsgi_client import send_request
|
||||
@@ -110,6 +111,10 @@ class APITestCase(TestCase):
|
||||
self.assertEqual(status, 400)
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_get_best_trials_of_preferential_study(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(n_generate=4, storage=storage)
|
||||
@@ -134,6 +139,10 @@ class APITestCase(TestCase):
|
||||
assert best_trials[0]["number"] == 0
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_report_preference(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(n_generate=4, storage=storage)
|
||||
@@ -168,6 +177,10 @@ class APITestCase(TestCase):
|
||||
assert worse.number == 1
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_report_preference_when_typo_mode(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(storage=storage, n_generate=3)
|
||||
@@ -192,6 +205,10 @@ class APITestCase(TestCase):
|
||||
self.assertEqual(status, 400)
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_change_component(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(storage=storage, n_generate=3)
|
||||
@@ -327,6 +344,10 @@ class APITestCase(TestCase):
|
||||
assert note_ver_key(0) not in study.system_attrs
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_skip_trial(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(n_generate=4, storage=storage)
|
||||
@@ -352,6 +373,10 @@ class APITestCase(TestCase):
|
||||
assert best_trials[0].number == 2
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_remove_history(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(storage=storage, n_generate=3)
|
||||
@@ -386,6 +411,10 @@ class APITestCase(TestCase):
|
||||
assert len(study.get_preferences()) == 0
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"),
|
||||
reason="Needs optuna.search_space",
|
||||
)
|
||||
def test_restore_history(self) -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(storage=storage, n_generate=3)
|
||||
|
||||
@@ -5,11 +5,16 @@ from typing import Any
|
||||
import optuna
|
||||
from optuna.trial import TrialState
|
||||
from optuna_dashboard._app import create_app
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
from .wsgi_client import send_request
|
||||
|
||||
|
||||
if version.parse(optuna.__version__) < version.parse("3.2.0"):
|
||||
pytest.skip("Study.metrics_name is introduced at v3.2.0", allow_module_level=True)
|
||||
|
||||
|
||||
def _validate_output(
|
||||
storage: optuna.storages.BaseStorage,
|
||||
correct_status: int,
|
||||
|
||||
@@ -5,6 +5,7 @@ import sys
|
||||
from typing import Callable
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import optuna
|
||||
from optuna.storages import BaseStorage
|
||||
from optuna_dashboard._preferential_history import _SYSTEM_ATTR_PREFIX_HISTORY
|
||||
from optuna_dashboard._preferential_history import NewHistory
|
||||
@@ -14,6 +15,7 @@ from optuna_dashboard._preferential_history import restore_history
|
||||
from optuna_dashboard._serializer import serialize_preference_history
|
||||
from optuna_dashboard.preferential import create_study
|
||||
from optuna_dashboard.preferential._system_attrs import _SYSTEM_ATTR_PREFIX_PREFERENCE
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
from .storage_supplier import parametrize_storages
|
||||
@@ -24,6 +26,10 @@ if TYPE_CHECKING:
|
||||
from optuna_dashboard._preferential_history import History
|
||||
|
||||
|
||||
if version.parse(optuna.__version__) < version.parse("3.4.0"):
|
||||
pytest.skip("Preferential optimization is introduced at v3.4.0", allow_module_level=True)
|
||||
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
pytest.skip("BoTorch dropped Python3.7 support", allow_module_level=True)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from optuna_dashboard._serializer import serialize_study_detail
|
||||
from optuna_dashboard._serializer import serialize_study_summary
|
||||
from optuna_dashboard._storage import get_study_summaries
|
||||
from optuna_dashboard.preferential import create_study
|
||||
from packaging import version
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -53,6 +54,9 @@ def test_serialize_numpy_floating() -> None:
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"), reason="Needs optuna.search_space"
|
||||
)
|
||||
def test_get_study_detail_is_preferential() -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
study = create_study(n_generate=4, storage=storage)
|
||||
@@ -80,6 +84,9 @@ def test_get_study_detail_is_not_preferential() -> None:
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 8), reason="BoTorch dropped Python3.7 support")
|
||||
@pytest.mark.skipif(
|
||||
version.parse(optuna.__version__) < version.parse("3.2.0"), reason="Needs optuna.search_space"
|
||||
)
|
||||
def test_get_study_summary_is_preferential() -> None:
|
||||
storage = optuna.storages.InMemoryStorage()
|
||||
create_study(n_generate=4, storage=storage)
|
||||
|
||||
Reference in New Issue
Block a user