PSLmodels / Tax-Brain

Tax-Brain is an integrator model for PSL tax models
http://taxbrain.pslmodels.org/
MIT License
9 stars 14 forks source link

COMP Error #62

Closed hdoupe closed 5 years ago

hdoupe commented 5 years ago

Traceback (most recent call last): File "/home/distributed/api/celery_app/init.py", line 71, in f outputs = func(*args, **kwargs) File "/home/distributed/api/celery_app/pslmodels_taxbrain_tasks.py", line 30, in sim return compconfig.run_model(meta_param_dict, adjustment) File "/opt/conda/lib/python3.7/site-packages/compconfig/functions.py", line 122, in run_model policy_mods = convert_adj(adjustment["policy"], meta_params.year.tolist()) File "/opt/conda/lib/python3.7/site-packages/compconfig/helpers.py", line 161, in convert_adj pol.implement_reform(new_adj) File "/opt/conda/lib/python3.7/site-packages/taxcalc/policy.py", line 119, in implement_reform self._update(reform, print_warnings, raise_errors) File "/opt/conda/lib/python3.7/site-packages/taxcalc/parameters.py", line 351, in _update raise ValueError('\n' + self.parameter_errors) ValueError: ERROR: 2026 ACTC_c value 2000.0 > max value 1000.0 for CTC_c ERROR: 2027 ACTC_c value 2000.0 > max value 1000.0 for CTC_c ERROR: 2028 ACTC_c value 2000.0 > max value 1000.0 for CTC_c ERROR: 2029 ACTC_c value 2000.0 > max value 1000.0 for CTC_c

andersonfrailey commented 5 years ago

@hdoupe this is an issue with the parameter value. In tax-calculator ACTC_c has a max value of CTC_c. CTC_c goes from 2000 to 1000 starting in 2026, which is what's causing the error. So the model and compconfig package are working as expected.

I'm not sure what the best solution would be for dealing with this kind of error. Maybe in the parameter validation process this kind of error could cause a different type of error message?

hdoupe commented 5 years ago

I think the quick and dirty solution is to catch the error in validate_inputs and set it under the "policy" section with the field name as "Parameter Error".

This could look like:

try:
    tc_adj = {
        "policy": convert_adj(adjustment["policy"],
                                meta_params.year.tolist()),
        "behavior": convert_behavior_adj(adjustment["behavior"])
    }
except ValueError as ve:
    errors_warnings["policy"]["errors"]["Parameter Error"] = str(e)

COMP will use "Parameter Error" for the parameter name associated with the error message.

MattHJensen commented 5 years ago

In tax-calculator ACTC_c has a max value of CTC_c. CTC_c goes from 2000 to 1000 starting in 2026, which is what's causing the error.

@andersonfrailey, I don't quite understand the reason for the ACTC_c max to be set at CTC_c. Do you? I'm happy to bring this up in the Tax-Calculator repo if you don't.

(specifics aside, getting the error message right def seems useful!).

andersonfrailey commented 5 years ago

@MattHJensen I do not, but I'll look through its history and try to figure it out. I'm not sure why it would need to be capped at CTC_c either. I'll open up an issue in Tax-Calc if I can't figure it out.