Merge pull request #727 from nabenabe0928/bug-fix/clear-cache-of-previous-tests

Clear cache before going to another tests in unit tests
This commit is contained in:
keisuke umezawa
2023-12-14 18:38:02 +09:00
committed by GitHub
4 changed files with 15 additions and 0 deletions
@@ -9,6 +9,7 @@ from playwright.sync_api import Page
import pytest
from ...test_server import make_test_server
from ...utils import clear_inmemory_cache
def make_test_storage() -> optuna.storages.InMemoryStorage:
@@ -43,6 +44,7 @@ def make_test_storage() -> optuna.storages.InMemoryStorage:
@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage
@@ -3,6 +3,7 @@ from playwright.sync_api import Page
import pytest
from ...test_server import make_test_server
from ...utils import clear_inmemory_cache
def make_test_storage() -> optuna.storages.InMemoryStorage:
@@ -23,6 +24,7 @@ def make_test_storage() -> optuna.storages.InMemoryStorage:
@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = make_test_storage()
return storage
@@ -5,10 +5,12 @@ from playwright.sync_api import Page
import pytest
from ..test_server import make_test_server
from ..utils import clear_inmemory_cache
@pytest.fixture
def storage() -> optuna.storages.InMemoryStorage:
clear_inmemory_cache()
storage = optuna.storages.InMemoryStorage()
return storage
+9
View File
@@ -0,0 +1,9 @@
from optuna_dashboard._storage import trials_cache
from optuna_dashboard._storage import trials_cache_lock
from optuna_dashboard._storage import trials_last_fetched_at
def clear_inmemory_cache() -> None:
with trials_cache_lock:
trials_cache.clear()
trials_last_fetched_at.clear()