idaes-pse icon indicating copy to clipboard operation
idaes-pse copied to clipboard

Parameter sweep `run_model` is hard to debug

Open Robbybp opened this issue 1 year ago • 6 comments
trafficstars

In ParameterSweepBase, we wrap run_model in a try/except with no specified exception. This seems a bit dangerous. For errors in solvers and other "black-box" subroutines, we probably want to record them. For other errors, e.g. typos, we probably want the sweep to fail immediately. Otherwise we can run an entire parameter sweep just to see something like ValueError: too many values to unpack for every item. The risk of odd errors increases as we write more complicated run_model methods. Right now I have scaling, re-initialization, solve, and validation steps in a run_model function that I'm using. My question is: Should we define an exception type that users must raise in order to be caught by the sweep runner? The downside is that users will have to know what types of exceptions to expect from their black-box subroutines, and will have to catch these and re-raise our exception type. I assume the current design was chosen intentionally, but am curious to hear the rationale for it.

Robbybp avatar Feb 27 '24 19:02 Robbybp