keras-team/keras-tuner

Number of consecutive failures raises TypeError instead of RuntimeError

Closed this issue · 0 comments

Describe the bug
Due to absent trial.message (None) the error for the maximum number of failed trials, a TypeError is raised instead of RuntimeError.

  File ".venv/lib/python3.9/site-packages/keras_tuner/engine/base_tuner.py", line 227, in search
    self.on_trial_end(trial)
  File ".venv/lib/python3.9/site-packages/keras_tuner/engine/base_tuner.py", line 331, in on_trial_end
    self.oracle.end_trial(trial)
  File ".venv/lib/python3.9/site-packages/keras_tuner/engine/oracle.py", line 108, in wrapped_func
    ret_val = func(*args, **kwargs)
  File ".venv/lib/python3.9/site-packages/keras_tuner/engine/oracle.py", line 435, in end_trial
    self._check_consecutive_failures()
  File ".venv/lib/python3.9/site-packages/keras_tuner/engine/oracle.py", line 388, in _check_consecutive_failures
    "Number of consecutive failures excceeded the limit "
TypeError: can only concatenate str (not "NoneType") to str

To Reproduce
https://colab.research.google.com/gist/fhausmann/92d8c2846c46c899861b920f1099ff58/untitled1.ipynb

Expected behavior
RuntimeError is raised instead of TypeError.

Additional context

Would you like to help us fix it?
Yes, I'll provide a fix.