From 6562da60cc0951e091d16dc89445925c35504e76 Mon Sep 17 00:00:00 2001 From: PavelMakarchuk Date: Thu, 19 Feb 2026 16:46:09 -0500 Subject: [PATCH] Handle ParameterNotFoundError gracefully in runner The runner crashed on PA records for 2024 because state_eitc triggers a ParameterNotFoundError for pa_eitc.match. The error handler only caught "does not exist" but not "was not found". Now catches both, matching exe.py behavior of returning 0 for missing parameters. Co-Authored-By: Claude Opus 4.6 --- changelog.d/fix-runner-parameter-not-found.fixed.md | 1 + policyengine_taxsim/runners/policyengine_runner.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog.d/fix-runner-parameter-not-found.fixed.md diff --git a/changelog.d/fix-runner-parameter-not-found.fixed.md b/changelog.d/fix-runner-parameter-not-found.fixed.md new file mode 100644 index 0000000..4ccf00d --- /dev/null +++ b/changelog.d/fix-runner-parameter-not-found.fixed.md @@ -0,0 +1 @@ +Handle missing parameter errors gracefully in PolicyEngineRunner instead of crashing. diff --git a/policyengine_taxsim/runners/policyengine_runner.py b/policyengine_taxsim/runners/policyengine_runner.py index d18b116..ad9e84d 100644 --- a/policyengine_taxsim/runners/policyengine_runner.py +++ b/policyengine_taxsim/runners/policyengine_runner.py @@ -1043,7 +1043,7 @@ def _extract_vectorized_results( arr = self._calc_tax_unit(sim, resolved, year_str) var_sum += arr except Exception as e: - if "does not exist" in str(e): + if "does not exist" in str(e) or "was not found" in str(e): if self.logs: print( f"Variable {resolved} not implemented, setting to 0" @@ -1061,7 +1061,7 @@ def _extract_vectorized_results( arr = self._calc_tax_unit(sim, resolved, year_str) result_array[state_mask] = arr[state_mask] except Exception as e: - if "does not exist" in str(e): + if "does not exist" in str(e) or "was not found" in str(e): if self.logs: print( f"Variable {resolved} not implemented, setting to 0" @@ -1085,7 +1085,8 @@ def _extract_vectorized_results( columns[taxsim_var] = np.round(arr, 2) except Exception as e: - if "does not exist" in str(e): + err_msg = str(e) + if "does not exist" in err_msg or "was not found" in err_msg: if self.logs: print( f"Variable {pe_var} not implemented, setting to 0"