NREL / celavi

Codebase for the Circular Economy Lifecycle Assessment and VIsualization (CELAVI) modeling framework.
https://nrel.github.io/celavi/
GNU General Public License v3.0
9 stars 7 forks source link

Warning statement problem - Exception within Exception #173

Closed tjlca closed 2 years ago

tjlca commented 2 years ago

I have changed print statements in PyLCIA CELAVI to warning statements for those times when the solver fails to provide results or inventory is missing or final demand calculation fails. When this warning is triggered the code should continue working.

However, due to PyLCIA being inside an exception (Scenario.py), the warning statement throws and error and the code stops. I think that is the issue from my understanding of the error file. The current fix error.1_cglr_oaat.uncdebug.txt is that I have a warnings.filterwarnings("ignore") in the des interface that suppresses all warnings from PyLCIA currently. Can this be rectified in any way? If the easy resolution is changing warning statements to print statements, I can do that.

rjhanes commented 2 years ago

PyLCIA is definitely not inside an exception in scenario.py - it's instantiated inside the setup method and then passed into the Context inside the execute method. The only exceptions I'm seeing in scenario.py are around file IO. I've done a quick check and I'm reasonably certain that the call to model_celavi_lci_insitu isn't in an exception at any level.

I'm not sure why raising a warning caused the code to stop, but looking at the warning on line 227 in insitu_emission.py, I don't see a problem with leaving the warning as a print statement, provided that the message isn't telling us something is wrong and the simulation should be stopped. Reading the code, it looks like the chksum is less than or equal to zero (hopefully never less than!) when there's no final demand for a particular material/stage/etc. As long as there's no more serious reason why chksum would be zero, then a print statement is fine - I'm not sure we even need a notification of a zero final demand.

tjlca commented 2 years ago

I will push a solution to this issue into the PR #168