cauldron / activity-browser

GUI for Brightway
GNU Lesser General Public License v3.0
0 stars 3 forks source link

Calculation will fail if no reference product is set #24

Open ughstudios opened 5 months ago

ughstudios commented 5 months ago

Updating AB

What happened?

The code tries to access a value named "reference product" when performing a calculation. However, that value may not always be set.

Relevant errors

ERROR  Traceback (most recent call last):   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/bwutils/calculations.py", line 24, in do_LCA_calculations     mlca = MLCA(cs_name)   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/bwutils/multilca.py", line 196, in __init__     f'{act["reference product"]} | '   File "/opt/homebrew/Caskroom/miniconda/base/envs/ab/lib/python3.10/site-packages/bw2data/backends/proxies.py", line 235, in __getitem__     raise KeyError KeyError  During handling of the above exception, another exception occurred:  Traceback (most recent call last):   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/layouts/tabs/LCA_results_tab.py", line 58, in generate_setup     new_tab = LCAResultsSubTab(data, self)   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/layouts/tabs/LCA_results_tabs.py", line 137, in __init__     self.mlca, self.contributions, self.mc = calculations.do_LCA_calculations(data)   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/bwutils/calculations.py", line 27, in do_LCA_calculations     raise BW2CalcError("LCA Failed", str(e)).with_traceback(e.__traceback__)   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/bwutils/calculations.py", line 24, in do_LCA_calculations     mlca = MLCA(cs_name)   File "/Users/danielgleason/Desktop/cauldron_activity_browser/activity-browser/activity_browser/bwutils/multilca.py", line 196, in __init__     f'{act["reference product"]} | '   File "/opt/homebrew/Caskroom/miniconda/base/envs/ab/lib/python3.10/site-packages/bw2data/backends/proxies.py", line 235, in __getitem__     raise KeyError bw2calc.errors.BW2CalcError: ('LCA Failed', '')

Operating system

MacOS

Conda environment

No response