Skip to content

Commit

Permalink
Merge pull request #950 from hdoupe/update-taxcalc
Browse files Browse the repository at this point in the history
Update Tax-Calculator and B-Tax
  • Loading branch information
hdoupe committed Jan 11, 2019
2 parents f1d4b2b + 540aea5 commit 6c0da7f
Show file tree
Hide file tree
Showing 23 changed files with 76 additions and 76 deletions.
12 changes: 12 additions & 0 deletions RELEASES.md
Expand Up @@ -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**
Expand Down
6 changes: 3 additions & 3 deletions 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
Expand Down
7 changes: 3 additions & 4 deletions distributed/Dockerfile
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions distributed/api/celery_tasks.py
Expand Up @@ -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
Expand Down Expand Up @@ -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"):
Expand All @@ -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
1 change: 1 addition & 0 deletions distributed/requirements.txt
Expand Up @@ -6,3 +6,4 @@ celery
requests-mock
requests
pytest
msgpack
2 changes: 1 addition & 1 deletion python_env_build.sh
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -28,3 +28,4 @@ python-dateutil
toolz
whitenoise
msgpack
psycopg2-binary
5 changes: 2 additions & 3 deletions webapp/apps/btax/helpers.py
Expand Up @@ -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__


#
Expand Down
10 changes: 2 additions & 8 deletions webapp/apps/btax/views.py
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions webapp/apps/dynamic/compute.py
Expand Up @@ -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', '')
Expand Down
12 changes: 3 additions & 9 deletions webapp/apps/dynamic/helpers.py
Expand Up @@ -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))

Expand Down
9 changes: 3 additions & 6 deletions webapp/apps/dynamic/views.py
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions webapp/apps/pages/views.py
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions webapp/apps/taxbrain/behaviors.py
Expand Up @@ -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

Expand Down Expand Up @@ -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 = {}
Expand Down
3 changes: 1 addition & 2 deletions webapp/apps/taxbrain/compute.py
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions webapp/apps/taxbrain/forms.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 8 additions & 4 deletions webapp/apps/taxbrain/helpers.py
Expand Up @@ -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'])
Expand All @@ -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 = []

Expand Down
6 changes: 4 additions & 2 deletions webapp/apps/taxbrain/param_displayers.py
Expand Up @@ -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():
Expand Down
7 changes: 5 additions & 2 deletions webapp/apps/taxbrain/tests/test_all.py
Expand Up @@ -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]
Expand Down
4 changes: 3 additions & 1 deletion webapp/apps/taxbrain/tests/test_helpers.py
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions webapp/apps/taxbrain/views.py
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions webapp/apps/test_assets/test_param_formatters.py
Expand Up @@ -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()


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion webapp/settings.py
Expand Up @@ -58,7 +58,7 @@
]


WEBAPP_VERSION = "1.7.6"
WEBAPP_VERSION = "1.7.7"

# Application definition

Expand Down

0 comments on commit 6c0da7f

Please sign in to comment.