Skip to content

Commit

Permalink
More informative OptimizerResult.message in case of exceptions
Browse files Browse the repository at this point in the history
So far only the exception message was stored if an exception occurred
during optimization with FidesOptimizer. This is often enough not
helpful at all.
Now this includes exception type / message / traceback.

Related to #1147
  • Loading branch information
dweindl committed Oct 25, 2023
1 parent 7e5da73 commit 72e0e7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pypesto/optimize/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,11 @@ def minimize(
try:
opt.minimize(x0)
msg = self._convert_exitflag_to_message(opt)
except RuntimeError as err:
msg = str(err)
except RuntimeError:
import sys
import traceback

msg = "\n".join(traceback.format_exception(*sys.exc_info()))

optimizer_result = OptimizerResult(
x=opt.x_min,
Expand Down

0 comments on commit 72e0e7b

Please sign in to comment.