Skip to content

Commit

Permalink
Log traceback in case of exceptions during optimizations
Browse files Browse the repository at this point in the history
So far, with `minimize(..., OptimizeOptions(allow_failed_starts=True))`
only the exception message was stored/logged, which is not always sufficiently
informative (see #1147).

Now we log the full exception type / message / traceback.

Closes #1147
  • Loading branch information
dweindl committed Oct 30, 2023
1 parent bb971a9 commit b90b6e0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pypesto/optimize/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ def wrapped_minimize(
)
except Exception as err:
if optimize_options.allow_failed_starts:
logger.error(f'start {id} failed: {err}')
import sys
import traceback

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

logger.error(f'start {id} failed:\n{trace}')
result = OptimizerResult(
x0=x0, exitflag=-1, message=str(err), id=id
)
Expand Down

0 comments on commit b90b6e0

Please sign in to comment.