optuna / optuna-dashboard

Real-time Web Dashboard for Optuna.
https://optuna-dashboard.readthedocs.io/en/latest/
Other
474 stars 81 forks source link

error showing studies #679

Open MertensDev opened 8 months ago

MertensDev commented 8 months ago

Description

Starting the dashboard works fine, both with sqlite and mysql. When I open the dashboard in the browser i see

Failed to fetch study (reason=internal server error)

The logs show the following:

Exception: 'list' object has no attribute 'get'
  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_bottle_util.py", line 31, in decorated
    response_body = view(*args, **kwargs)

  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_app.py", line 227, in get_study_detail
    return serialize_study_detail(

  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_serializer.py", line 152, in serialize_study_detail
    serialized["trials"] = [

  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_serializer.py", line 153, in <listcomp>
    serialize_frozen_trial(summary._study_id, trial, system_attrs) for trial in trials

  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_serializer.py", line 240, in serialize_frozen_trial
    "fixed_params": [

  File "/Users/username/projects/project/.env/lib/python3.9/site-packages/optuna_dashboard/_serializer.py", line 241, in <listcomp>
    {"name": param_name, "param_external_value": str(fixed_params.get(param_name, None))}

How to Reproduce

  1. Optuna's objective function is
def tpe_objective_fn(trial, observations):
    num_steps = observations["lb"].shape[0]
    num_heat_sources = observations["lb"].shape[1]
    lb = observations["lb"].flatten()
    ub = observations["ub"].flatten()
    chosen_parameters = []
    for step in range(num_steps):
        for idx in range(num_heat_sources):
            chosen_parameters.append(
                trial.suggest_float(f"tech_param_{step}_{idx}", lb[idx], ub[idx])
            )

    cost = cost_function(
        chosen_parameters,
        num_steps,
    )
    return cost
  1. Run optuna-dashboard with optuna-dashboard mysql://user:password@127.0.0.1:3307/optuna
  2. Open http://127.0.0.1:8080/ page.
  3. An error occurs.

Python version

3.9.6

Optuna version

3.4.0

optuna-dashboard version or git revision

0.13.0

Web browser

Chrome

contramundum53 commented 6 months ago

@MertensDev Thanks for your bug report! Could you give us the reproducible code for optimization? If you could make it shorter, that would be better.

adjeiv commented 6 months ago

I think https://github.com/optuna/optuna/issues/5113 is relevant; I would guess you might be using a list rather than a dictionary for the parameters, which end up as the fixed_params that is expected to be a dictionary.