jrbourbeau / dask-optuna

Scale Optuna with Dask
https://jrbourbeau.github.io/dask-optuna/
MIT License
35 stars 6 forks source link

Optuna 2.4 | Can't instantiate abstract class DaskStorage #22

Open quantabox opened 3 years ago

quantabox commented 3 years ago

Steps to recreate

pip install dask_optuna conda install python

Select Package Versions

dask_optuna: 0.0.2
optuna: 2.4.0 
scipy: 1.4.0
numpy: 1.19

Execute example script

import joblib
import dask.distributed
import dask_optuna

def objective(trial):
    x = trial.suggest_uniform("x", -10, 10)
    return (x - 2) ** 2

with dask.distributed.Client() as client:
    # Create a study using Dask-compatible storage
    storage = dask_optuna.DaskStorage()
    study = optuna.create_study(storage=storage)
    # Optimize in parallel on your Dask cluster
    with joblib.parallel_backend("dask"):
        study.optimize(objective, n_trials=100, n_jobs=-1)
    print(f"best_params = {study.best_params}")

error message:

  File "<stdin>", line 3, in <module>
TypeError: Can't instantiate abstract class DaskStorage with abstract methods get_study_directions, set_study_directions, set_trial_values

the example works fine with optuna: 2.3.0.

jrbourbeau commented 3 years ago

Thanks for reporting this issue @quantabox! There were some known changes in the Optuna 2.4 release which broke the DaskStorage class here. We're working to incorporate DaskStorage directly into Optuna over in https://github.com/optuna/optuna/pull/2023 which will address the changes in the Optuna 2.4 release. In the meantime, as you've pointed out, I'd recommend sticking with optuna < 2.4.0 for now

fonnesbeck commented 3 years ago

This still occurs in 2.5.0

LeoFeilke commented 3 years ago

Any news on this issue? Cant use any RDB storage with Optuna 2.3.0, DaskStorage included.

eracle commented 3 years ago

Same error here, it seems to not work even with Optuna 2.3.0

Silk760 commented 3 years ago

same issue here, any update

deepakagrawal commented 3 years ago

Same error here.

pseudotensor commented 2 years ago

same

pseudotensor commented 2 years ago

@jrbourbeau given the work in optuna is difficult to complete, I wonder if there is a patch you could recommend for this repo to work with Optuna 2.5+?

Sarrae1406 commented 2 years ago

Issue still persists with version optuna 2.10.0.

TypeError: Can't instantiate abstract class DaskStorage with abstract methods get_study_directions, set_study_directions, set_trial_values

daddydrac commented 2 years ago

Error still persists:

TypeError                                 Traceback (most recent call last)
Input In [26], in <cell line: 5>()
      3 client_cluster = Client(cluster)
      5 with client_cluster as client:
----> 6     storage = dask_optuna.DaskStorage()
      7     study = optuna.create_study(
      8         study_name="pytorch-mlflow-optuna", 
      9         direction="minimize",
     10         storage=storage,
     11         sampler=optuna.samplers.TPESampler(search_space)
     12     )
     13     with joblib.parallel_backend("dask"):

TypeError: Can't instantiate abstract class DaskStorage with abstract methods get_study_directions, set_study_directions, set_trial_values
kurvaraviteja355 commented 2 years ago

    with Client() as client:
            # Create a study using Dask-compatible storage
            dask_storage = dask_optuna.DaskStorage('sqlite:///example.db')
            study = optuna.create_study(storage=dask_storage)
            with joblib.parallel_backend("dask"):
                study.optimize(optimize_model.objective, n_trials=50, n_jobs=-1)
            print(f"best_params = {study.best_params}")
            print('Best params{} and best score{}'.format(study.best_params, study.best_value))

            best_params = study.best_params

Error still exist in 2.10.0 version

Traceback (most recent call last): File "c:/Users/raviteja.kurva/OneDrive - profiflitzer.de/Documents/Python_Scripts/Microsoft/Microsoft_Forecast/src/surface_model_train.py", line 391, in dask_storage = dask_optuna.DaskStorage('sqlite:///example.db') TypeError: Can't instantiate abstract class DaskStorage with abstract methods get_study_directions, set_study_directions, set_trial_values

inzamamsafi commented 2 years ago

Getting the same error with version 0.0.2.

Is there any fix?

cherusk commented 1 year ago

FWIW Still the case for optuna 3.0.5