From 0941719b2717cbeafbaaa85eb4a7e0c38a9a9db4 Mon Sep 17 00:00:00 2001 From: Byron Pullutasig <115118857+bpulluta@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:32:55 -0600 Subject: [PATCH] fix offgrid bug --- reoptjl/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reoptjl/views.py b/reoptjl/views.py index 4cf1a8b4b..2bd5e1651 100644 --- a/reoptjl/views.py +++ b/reoptjl/views.py @@ -1631,13 +1631,19 @@ def get_bau_values(scenarios: List[Dict[str, Any]], config: List[Dict[str, Any]] df_gen = flatten_dict(scenario['full_data']) for entry in config: bau_func = entry.get("bau_value") + # Try to apply the BAU function, and if it fails, set value to 0 if bau_func: - bau_values_per_scenario[run_uuid][entry["label"]] = bau_func(df_gen) + try: + bau_values_per_scenario[run_uuid][entry["label"]] = bau_func(df_gen) + except Exception: + bau_values_per_scenario[run_uuid][entry["label"]] = 0 + else: + bau_values_per_scenario[run_uuid][entry["label"]] = 0 return bau_values_per_scenario except Exception: log_and_raise_error('get_bau_values') - + def process_scenarios(scenarios: List[Dict[str, Any]], reopt_data_config: List[Dict[str, Any]]) -> pd.DataFrame: try: bau_values_per_scenario = get_bau_values(scenarios, reopt_data_config)