diff --git a/RELEASES.md b/RELEASES.md index 28340a80..b6704e07 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -4,6 +4,18 @@ Go [here](https://github.com/OpenSourcePolicyCenter/PolicyBrain/pulls?q=is%3Apr+is%3Aclosed) for a complete commit history. +Release 1.7.7 on 2019-01-14 +---------------------------- +**Major Changes** +- None + +**Minor Changes** +- [#950](https://github.com/ospc-org/ospc.org/pull/950) - Update Tax-Calculator and B-Tax - Hank Doupe + +**Bug Fixes** +- None + + Release 1.7.6 on 2018-11-09 ---------------------------- **Major Changes** diff --git a/conda-requirements.txt b/conda-requirements.txt index 22788bbf..9e0d438d 100644 --- a/conda-requirements.txt +++ b/conda-requirements.txt @@ -1,7 +1,7 @@ nomkl -taxcalc==0.22.2 -btax==0.2.2 -ogusa==0.5.11 +taxcalc==0.24 +btax==0.2.8 +ogusa==0.5.12 numba>=0.33.0 pandas>=0.22.0 pillow diff --git a/distributed/Dockerfile b/distributed/Dockerfile index 3f2ea844..e0976fd7 100644 --- a/distributed/Dockerfile +++ b/distributed/Dockerfile @@ -9,12 +9,11 @@ COPY requirements.txt home/distributed WORKDIR /home/distributed RUN conda update conda -RUN conda config --add channels ospc -RUN conda config --add channels ospc/label/dev +RUN conda config --add channels pslmodels RUN conda config --append channels conda-forge -RUN conda install python=3.6 numpy>=1.12.1 pandas>=0.23.0 taxcalc=0.22.2 \ - btax=0.2.2 ogusa=0.5.11 matplotlib>=3.0.1 numba six bokeh>=0.12.7 mock xlrd \ +RUN conda install python=3.6 numpy>=1.12.1 pandas>=0.23.0 taxcalc=0.24.0 \ + btax=0.2.8 matplotlib>=3.0.1 numba six bokeh>=0.12.7 mock xlrd \ sphinx nomkl RUN pip install -r requirements.txt diff --git a/distributed/api/celery_tasks.py b/distributed/api/celery_tasks.py index 56abde16..accd1099 100644 --- a/distributed/api/celery_tasks.py +++ b/distributed/api/celery_tasks.py @@ -43,9 +43,8 @@ def dropq_task(year_n, user_mods, first_budget_year, use_puf_not_cps=True, ) # Add taxcalc version to results - vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] - results['dropq_version'] = vinfo['version'] + results['taxcalc_version'] = taxcalc.__version__ + results['dropq_version'] = taxcalc.__version__ json_res = json.dumps(results) return json_res @@ -105,7 +104,7 @@ def btax_async(user_mods, start_year): user_mods['start_year'] = start_year print("submitting btax data: ", user_mods) results = {} - tables = json.loads(runner_json_tables(**user_mods)) + tables = json.loads(runner_json_tables(test_run=False, **user_mods)) if tables.get("json_table"): results.update(tables["json_table"]) if tables.get("dataframes"): @@ -115,10 +114,8 @@ def btax_async(user_mods, start_year): results["dataframes"] = dataframes else: results.update(tables) - vinfo = taxcalc._version.get_versions() - results['taxcalc_version'] = vinfo['version'] - results['dropq_version'] = vinfo['version'] - binfo = btax._version.get_versions() - results['btax_version'] = binfo['version'] + results['taxcalc_version'] = taxcalc.__version__ + results['dropq_version'] = taxcalc.__version__ + results['btax_version'] = btax.__version__ json_res = json.dumps(results) return json_res diff --git a/distributed/requirements.txt b/distributed/requirements.txt index 88b6579b..8d04e5bf 100644 --- a/distributed/requirements.txt +++ b/distributed/requirements.txt @@ -6,3 +6,4 @@ celery requests-mock requests pytest +msgpack \ No newline at end of file diff --git a/python_env_build.sh b/python_env_build.sh index eb619dd9..cbc61086 100755 --- a/python_env_build.sh +++ b/python_env_build.sh @@ -6,7 +6,7 @@ echo 'activating env: pb_env' source activate pb_env echo 'installing conda packages' -conda install -c ospc -c defaults --file conda-requirements.txt --yes +conda install -c pslmodels -c defaults --file conda-requirements.txt --yes echo 'pip installing remaining requirements' diff --git a/requirements.txt b/requirements.txt index d25c82f5..9ea8dea0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,3 +28,4 @@ python-dateutil toolz whitenoise msgpack +psycopg2-binary diff --git a/webapp/apps/btax/helpers.py b/webapp/apps/btax/helpers.py index 76f6c1e5..550e64ff 100644 --- a/webapp/apps/btax/helpers.py +++ b/webapp/apps/btax/helpers.py @@ -34,13 +34,12 @@ 'btax_depr_7yr', 'btax_depr_10yr', 'btax_depr_15yr','btax_depr_20yr', 'btax_depr_25yr', 'btax_depr_27_5yr', 'btax_depr_39yr'] -BTAX_OTHER = ['btax_other_hair', 'btax_other_corpeq', +BTAX_OTHER = [ 'btax_other_hair_c', 'btax_other_hair_nc', 'btax_other_corpeq', 'btax_other_proptx','btax_other_invest'] BTAX_ECON = ['btax_econ_nomint', 'btax_econ_inflat',] -BTAX_VERSION_INFO = btax._version.get_versions() -BTAX_VERSION = BTAX_VERSION_INFO['version'] +BTAX_VERSION = btax.__version__ # diff --git a/webapp/apps/btax/views.py b/webapp/apps/btax/views.py index e5acb2a9..4f40467e 100644 --- a/webapp/apps/btax/views.py +++ b/webapp/apps/btax/views.py @@ -54,16 +54,10 @@ dropq_compute = DropqComputeBtax() -BTAX_VERSION_INFO = btax._version.get_versions() - -BTAX_VERSION = BTAX_VERSION_INFO['version'] +BTAX_VERSION = btax.__version__ WEBAPP_VERSION = settings.WEBAPP_VERSION - - -tcversion_info = taxcalc._version.get_versions() - -TAXCALC_VERSION = tcversion_info['version'] +TAXCALC_VERSION = taxcalc.__version__ JOB_PROC_TIME_IN_SECONDS = 30 diff --git a/webapp/apps/dynamic/compute.py b/webapp/apps/dynamic/compute.py index bffa0ff1..df396bdc 100644 --- a/webapp/apps/dynamic/compute.py +++ b/webapp/apps/dynamic/compute.py @@ -10,8 +10,7 @@ from .helpers import filter_ogusa_only from ..constants import START_YEAR -dqversion_info = taxcalc._version.get_versions() -dropq_version = dqversion_info['version'] +dropq_version = taxcalc.__version__ NUM_BUDGET_YEARS = int(os.environ.get('NUM_BUDGET_YEARS', 10)) #Hard fail on lack of dropq workers dropq_workers = os.environ.get('DROPQ_WORKERS', '') diff --git a/webapp/apps/dynamic/helpers.py b/webapp/apps/dynamic/helpers.py index cfadbfca..11d0a427 100644 --- a/webapp/apps/dynamic/helpers.py +++ b/webapp/apps/dynamic/helpers.py @@ -96,15 +96,9 @@ def normalize(x): # import taxcalc -tcversion_info = taxcalc._version.get_versions() -#ogversion_info = {u'full-revisionid': u'9ae018afc6c80b10fc19684d7ba9aa1729aa2f47', - #u'dirty': False, u'version': u'0.1.1', u'error': None} - -version_path = os.path.join(os.path.split(__file__)[0], "ogusa_version.json") -with open(version_path, "r") as f: - ogversion_info = json.load(f) -ogusa_version = ".".join([ogversion_info['version'], - ogversion_info['full-revisionid'][:6]]) +import ogusa +tcversion_info = taxcalc.__version__ +ogusa_version = ogusa.__version__ NUM_BUDGET_YEARS = int(os.environ.get('NUM_BUDGET_YEARS', 10)) diff --git a/webapp/apps/dynamic/views.py b/webapp/apps/dynamic/views.py index b289be24..3c9230eb 100644 --- a/webapp/apps/dynamic/views.py +++ b/webapp/apps/dynamic/views.py @@ -64,14 +64,11 @@ from ..formatters import format_dynamic_params, get_version -tcversion_info = taxcalc._version.get_versions() -TAXCALC_VERSION = tcversion_info['version'] +TAXCALC_VERSION = taxcalc.__version__ # TODO: use import ogusa; ogusa.__version__ -version_path = os.path.join(os.path.split(__file__)[0], "ogusa_version.json") -with open(version_path, "r") as f: - ogversion_info = json.load(f) -OGUSA_VERSION = ogversion_info['version'] +import ogusa +OGUSA_VERSION = ogusa.__version__ from django.conf import settings WEBAPP_VERSION = settings.WEBAPP_VERSION diff --git a/webapp/apps/pages/views.py b/webapp/apps/pages/views.py index 388d495a..194e48ac 100644 --- a/webapp/apps/pages/views.py +++ b/webapp/apps/pages/views.py @@ -15,10 +15,8 @@ import btax import taxcalc -BTAX_VERSION_INFO = btax._version.get_versions() -TAXCALC_VERSION_INFO = taxcalc._version.get_versions() -BTAX_VERSION = BTAX_VERSION_INFO['version'] -TAXCALC_VERSION = TAXCALC_VERSION_INFO['version'] +BTAX_VERSION = btax.__version__ +TAXCALC_VERSION = taxcalc.__version__ BLOG_URL = os.environ.get('BLOG_URL', 'www.ospc.org') EMAIL_DEFAULT = '1' diff --git a/webapp/apps/taxbrain/behaviors.py b/webapp/apps/taxbrain/behaviors.py index 7b34faf6..503b7687 100644 --- a/webapp/apps/taxbrain/behaviors.py +++ b/webapp/apps/taxbrain/behaviors.py @@ -11,7 +11,8 @@ from distutils.version import LooseVersion from .helpers import (rename_keys, reorder_lists, PRE_TC_0130_RES_MAP, - REORDER_LT_TC_0130_DIFF_LIST, DIFF_TABLE_IDs) + REORDER_LT_TC_0130_DIFF_LIST, DIFF_TABLE_IDs, + default_taxcalc_data) from ..constants import TAXCALC_VERS_RESULTS_BACKWARDS_INCOMPATIBLE from . import param_formatters @@ -65,8 +66,7 @@ def set_fields(self, upstream_obj, nonparam_fields=None): 3. Do more specific type checking--in particular, check if field is the type that Tax-Calculator expects from this param """ - default_data = upstream_obj.default_data(start_year=self.start_year, - metadata=True) + default_data = default_taxcalc_data(upstream_obj, self.start_year) if self.raw_input_fields is None: self.raw_input_fields = {} diff --git a/webapp/apps/taxbrain/compute.py b/webapp/apps/taxbrain/compute.py index 85430a0a..897da48f 100644 --- a/webapp/apps/taxbrain/compute.py +++ b/webapp/apps/taxbrain/compute.py @@ -11,8 +11,7 @@ import requests_mock requests_mock.Mocker.TEST_PREFIX = 'dropq' -dqversion_info = taxcalc._version.get_versions() -dropq_version = dqversion_info['version'] +dropq_version = taxcalc.__version__ NUM_BUDGET_YEARS = int(os.environ.get('NUM_BUDGET_YEARS', 10)) NUM_BUDGET_YEARS_QUICK = int(os.environ.get('NUM_BUDGET_YEARS_QUICK', 1)) #Hard fail on lack of dropq workers diff --git a/webapp/apps/taxbrain/forms.py b/webapp/apps/taxbrain/forms.py index 108c9f78..456ac29f 100644 --- a/webapp/apps/taxbrain/forms.py +++ b/webapp/apps/taxbrain/forms.py @@ -112,12 +112,12 @@ def add_errors_on_extra_inputs(self): "Extra input '{0}' not allowed".format(_input)) all_fields = self.cleaned_data['raw_input_fields'] - default_policy = getattr(self.Meta, 'default_policy', None) + default_policy_data = getattr(self.Meta, 'default_policy_data', None) allowed_fields = getattr(self.Meta, 'allowed_fields', None) for _field in all_fields: - if default_policy: + if default_policy_data: try: - get_default_policy_param(_field, default_policy) + get_default_policy_param(_field, default_policy_data) except ParameterLookUpException as exn: self.add_error(None, str(exn)) elif _field not in allowed_fields: @@ -308,10 +308,10 @@ class Meta: fields = ['first_year', 'data_source', 'raw_input_fields', 'input_fields'] start_year = int(START_YEAR) - default_policy = taxcalc.Policy.default_data( - start_year=int(START_YEAR), - metadata=True - ) + pol = taxcalc.Policy() + pol.set_year(int(START_YEAR)) + default_policy_data = pol.metadata() + defaults_key = (start_year, True) if defaults_key not in TAXCALC_DEFAULTS: TAXCALC_DEFAULTS[defaults_key] = default_policy( diff --git a/webapp/apps/taxbrain/helpers.py b/webapp/apps/taxbrain/helpers.py index 05ef8bb6..566cad5b 100644 --- a/webapp/apps/taxbrain/helpers.py +++ b/webapp/apps/taxbrain/helpers.py @@ -167,11 +167,16 @@ def round_gt_one(x): return rounded -def default_taxcalc_data(cls, start_year, metadata=False): +def default_taxcalc_data(cls, start_year, metadata=True): ''' Call the default data function on the given class for the given start year with meatadata flag ''' - dd = cls.default_data(metadata=metadata, start_year=start_year) + if cls == taxcalc.Policy: + pol = taxcalc.Policy() + pol.set_year(start_year) + dd = pol.metadata() + else: #cls == taxcalc.Behavior): + dd = taxcalc.Behavior()._vals if metadata: for k in dd: dd[k]['value'] = round_gt_one_to_nearest_int(dd[k]['value']) @@ -184,8 +189,7 @@ def default_taxcalc_data(cls, start_year, metadata=False): # Prepare user params to send to DropQ/Taxcalc # -tcversion_info = taxcalc._version.get_versions() -taxcalc_version = tcversion_info['version'] +taxcalc_version = taxcalc.__version__ TAXCALC_COMING_SOON_FIELDS = [] diff --git a/webapp/apps/taxbrain/param_displayers.py b/webapp/apps/taxbrain/param_displayers.py index 9b5ed561..c5785e86 100644 --- a/webapp/apps/taxbrain/param_displayers.py +++ b/webapp/apps/taxbrain/param_displayers.py @@ -202,8 +202,10 @@ def nested_form_parameters(budget_year=2017, use_puf_not_cps=True, defaults=None): # defaults are None unless we are testing if defaults is None: - defaults = taxcalc.Policy.default_data(metadata=True, - start_year=budget_year) + pol = taxcalc.Policy() + pol.set_year(budget_year) + defaults = pol.metadata() + groups = parse_top_level(defaults) for x in groups: for y, z in x.items(): diff --git a/webapp/apps/taxbrain/tests/test_all.py b/webapp/apps/taxbrain/tests/test_all.py index d20ea88c..a9e2352b 100644 --- a/webapp/apps/taxbrain/tests/test_all.py +++ b/webapp/apps/taxbrain/tests/test_all.py @@ -216,8 +216,11 @@ def test_arrange_totals_by_row(self): def test_default_taxcalc_data(self): import math dd = default_taxcalc_data(taxcalc.policy.Policy, start_year=2017) - dd_raw = taxcalc.policy.Policy.default_data(start_year=2017) - dd_meta = default_taxcalc_data(taxcalc.policy.Policy, start_year=2017, metadata=True) + dd = {k: dd[k]['value'] for k in dd} + pol = taxcalc.Policy() + pol.set_year(2017) + dd_meta = pol.metadata() + dd_raw = {k: dd_meta[k]["value"] for k in dd_meta} floored_std_aged = list(map(math.floor, dd['_STD_Aged'][0])) assert dd['_STD_Aged'] == [floored_std_aged] assert dd_meta['_STD_Aged']['value'] == [floored_std_aged] diff --git a/webapp/apps/taxbrain/tests/test_helpers.py b/webapp/apps/taxbrain/tests/test_helpers.py index 06aacaec..7d42ff0b 100644 --- a/webapp/apps/taxbrain/tests/test_helpers.py +++ b/webapp/apps/taxbrain/tests/test_helpers.py @@ -207,7 +207,9 @@ def test_taxbrain_TaxCalcParam(): to make sure that the values are set correctly for display to the user. """ - dd = taxcalc.Policy.default_data(metadata=True, start_year=2017) + pol = taxcalc.Policy() + pol.set_year(2017) + dd = pol.metadata() for param_name in dd: tc_param = TaxCalcParam(param_name, dd[param_name], 2017) diff --git a/webapp/apps/taxbrain/views.py b/webapp/apps/taxbrain/views.py index 8c77de5e..8a619993 100644 --- a/webapp/apps/taxbrain/views.py +++ b/webapp/apps/taxbrain/views.py @@ -67,9 +67,7 @@ WEBAPP_VERSION = settings.WEBAPP_VERSION -tcversion_info = taxcalc._version.get_versions() - -TAXCALC_VERSION = tcversion_info['version'] +TAXCALC_VERSION = taxcalc.__version__ JOB_PROC_TIME_IN_SECONDS = 35 diff --git a/webapp/apps/test_assets/test_param_formatters.py b/webapp/apps/test_assets/test_param_formatters.py index eab5c616..f1bd11d2 100644 --- a/webapp/apps/test_assets/test_param_formatters.py +++ b/webapp/apps/test_assets/test_param_formatters.py @@ -22,8 +22,9 @@ @pytest.fixture def default_params_Policy(): - return taxcalc.Policy.default_data(start_year=START_YEAR, - metadata=True) + pol = taxcalc.Policy() + pol.set_year(2017) + return pol.metadata() ############################################################################### diff --git a/webapp/settings.py b/webapp/settings.py index e5255dcb..ba694e62 100644 --- a/webapp/settings.py +++ b/webapp/settings.py @@ -58,7 +58,7 @@ ] -WEBAPP_VERSION = "1.7.6" +WEBAPP_VERSION = "1.7.7" # Application definition