mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user