import joblib
import optuna
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:
distributed.core - ERROR - Exception while handling op optuna_get_trial
Traceback (most recent call last):
File "/home/mcchan3/.conda/envs/dask_optuna_test2/lib/python3.7/site-packages/distributed/core.py", line 516, in handle_comm
result = handler(comm, **msg)
File "/home/mcchan3/.conda/envs/dask_optuna_test2/lib/python3.7/site-packages/dask_optuna/storage.py", line 244, in get_trial
return serialize_frozentrial(trial)
File "/home/mcchan3/.conda/envs/dask_optuna_test2/lib/python3.7/site-packages/dask_optuna/serialize.py", line 32, in serialize_frozentrial
data[attr] = data.pop(f"_{attr}")
KeyError: '_number'
Select Package Versions
Execute example script
error message:
What seems to be the problem here? Thank you!