Skip to content

Commit

Permalink
Optuna 3.1 support (#33)
Browse files Browse the repository at this point in the history
* optuna 3.1 debug

* cleanup

* cleanup

* cleanup
  • Loading branch information
bcebere authored Jan 19, 2023
1 parent 5f9ba95 commit 47f649e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ install_requires =
torch>=1.10.0
numpy>=1.20
catboost>=1.0.5
optuna>=2.10
optuna>=3.1
loguru==.0.6.0
xgboost>=1.6.1
miracle-imputation>=0.1.3
Expand Down
12 changes: 8 additions & 4 deletions src/hyperimpute/utils/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# third party
import optuna
from optuna.storages import JournalRedisStorage, JournalStorage
import redis

# hyperimpute absolute
Expand All @@ -21,17 +22,16 @@ def __init__(
):
self.url = f"redis://{host}:{port}/"

self._optuna_storage = optuna.storages.RedisStorage(url=self.url)
self._optuna_storage = JournalStorage(JournalRedisStorage(url=self.url))
self._client = redis.Redis.from_url(self.url)

def optuna(self) -> optuna.storages.RedisStorage:
def optuna(self) -> JournalStorage:
return self._optuna_storage

def client(self) -> redis.Redis:
return self._client


backend = RedisBackend()
threshold = 40


Expand Down Expand Up @@ -104,7 +104,11 @@ def create_study(
patience: int = threshold,
) -> Tuple[optuna.Study, ParamRepeatPruner]:

storage_obj = backend.optuna()
try:
backend = RedisBackend()
storage_obj = backend.optuna()
except BaseException:
storage_obj = None

try:
study = optuna.create_study(
Expand Down
6 changes: 4 additions & 2 deletions src/hyperimpute/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
__version__ = "0.1.12"
MAJOR_VERSION = "0.1"
__version__ = "0.1.13"

MAJOR_VERSION = ".".join(__version__.split(".")[:-1])
MINOR_VERSION = __version__.split(".")[-1]

0 comments on commit 47f649e

Please sign in to comment.