Skip to content

Commit

Permalink
revise error message for better upgrading (keras-team#776)
Browse files Browse the repository at this point in the history
Co-authored-by: Haifeng Jin <haifeng-jin@users.noreply.github.com>
  • Loading branch information
haifeng-jin and haifeng-jin authored Dec 4, 2022
1 parent 5cbaa1a commit 41693aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion keras_tuner/engine/tuner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,10 @@ def run_trial(self, trial, *fit_args, **fit_kwargs):
trial.trial_id, {"loss": min(history.history["loss"])}
)

with pytest.raises(errors.FatalTypeError, match="return the metrics directly"):
with pytest.raises(
errors.FatalTypeError,
match="`self\.oracle\.update_trial\(trial_id, metrics\)`",
):
assert_found_best_score(tmp_path, MockHyperModel(), MyTuner)


Expand Down
8 changes: 5 additions & 3 deletions keras_tuner/engine/tuner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@ def validate_trial_results(results, objective, func_name):
)
if func_name == "Tuner.run_trial()":
error_message += (
"\nIf you are calling Oracle.update_trial() "
"in Tuner.run_trial() to report the metrics, "
"please remove the call and return the metrics directly."
"\nIf you are calling "
"`self.oracle.update_trial(trial_id, metrics)` "
"in `Tuner.run_trial()` to report the metrics, "
"please remove the call and `return metrics` "
"in `Tuner.run_trial()` instead."
)
raise errors.FatalTypeError(error_message)

Expand Down

0 comments on commit 41693aa

Please sign in to comment.