SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
52 stars 41 forks source link

Bumps errors are being eaten making debugging difficult #2481

Open butlerpd opened 1 year ago

butlerpd commented 1 year ago
          Unfortunately the bumps errors are being eaten, but we should be able so show them by changing

https://github.com/SasView/sasview/blob/8ccf562c8d593ababc1d010e3adc632f04037dea/src/sas/sascalc/fit/BumpsFitting.py#L291

to

assert …, f"Bumps failed with:\n{result['errors']}"

Originally posted by @pkienzle in https://github.com/SasView/sasview/issues/2451#issuecomment-1480324231

lucas-wilkins commented 1 year ago

Shouldn't really be relying on assert statements these days and they should be turned off in deployed code. If it's "user facing" (including packages used for scripting) it should raise an exception instead, and have type hints that indicate not giving it None.

pkienzle commented 1 year ago

Nothing "these days" about it. Even in python 2.0 the -O option stripped assert statements from running code.

That's still the only thing it does.* We don't gain any performance if we convert asserts to conditionals, so there is no reason for us to run the program with -O and no need to convert the asserts.

It might matter if sascalc were a library where we no longer have control over the execution environment.

* -O also sets __debug__ = False.