Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TaxBrain input page based on new info from current_law_policy.json #436

Closed
MattHJensen opened this issue Dec 16, 2016 · 11 comments
Closed
Assignees
Milestone

Comments

@MattHJensen
Copy link
Contributor

PSLmodels/Tax-Calculator#1109 makes it so that current_law_policy.json fully specifies the content and layout of the TaxBrain input page to a human interpreter. A major update to the TaxBrain input page will be necessary when that PR is merged to reflect all of the new parameters available.

@MattHJensen
Copy link
Contributor Author

MattHJensen commented Dec 22, 2016

This is ready now that PSLmodels/Tax-Calculator#1109 is merged. After the final b1 milestone is cleared, this should be the next big priority.

cc @talumbau.

@brittainhard
Copy link
Contributor

@MattHJensen is the idea here to manually update the inputs on the taxbrain page when the law policy changes?

@MattHJensen
Copy link
Contributor Author

@brittainhard asked:

is the idea here to manually update the inputs on the taxbrain page when the law policy changes?

Yes, that's the idea for now.

After we have some experience with that process, we can make a decision about whether it is worth the effort to refactor the TaxBrain backend to automatically generate from current_law_policy.json. (see #435 for one approach we might consider at that time).

@brittainhard
Copy link
Contributor

@MattHJensen looking at this more, it seems like we are adding another big feature -- the ability to set year parameters for inputs themselves, rather than just a blanket parameter set by the Start Year dropdown. Am I reading that correctly?

@MattHJensen
Copy link
Contributor Author

@brittainhard asked:

it seems like we are adding another big feature -- the ability to set year parameters for inputs themselves, rather than just a blanket parameter set by the Start Year dropdown. Am I reading that correctly?

No. The only changes should be adding some fields, reorganizing the ordering of the fields, renaming some sections and subsections, and adding new sections.

@brittainhard
Copy link
Contributor

Ahh, okay. I was reading too much into that json file.

@MattHJensen
Copy link
Contributor Author

Earlier @brittainhard asked:

@MattHJensen is the idea here to manually update the inputs on the taxbrain page when the law policy changes?

To which I replied:

Yes, that's the idea for now.

After we have some experience with that process, we can make a decision about whether it is worth the effort to refactor the TaxBrain backend to automatically generate from current_law_policy.json. (see #435 for one approach we might consider at that time).

I should clarify:

The values of the parameters should continue to be pulled over automatically as they are now. There should be no manual update for parameter values.

The manual update will be when we add new parameters, rename them, or change their sections.

@brittainhard
Copy link
Contributor

@MattHJensen @talumbau I'll give you an update on where I am.

I have created two functions that take the JSON from taxcalc.Policy, and parsed them into dictionaries that separate the fields based on the section_1 attribute. These, in turn, are separated into subcategories based on the section_2 attribute. The result is a nested structure containing lists of the data. This keeps the order intact based on the data grabbed from the Policy class. All that is left for this part of the task is to change the templating to parse this new structure.

There is a problem on the taxcalc side, however. The lines here do not retain the order of current_law_policy.json. It is reading the JSON directly into a dictionary, which does not preserve order. Because of the way Python reads JSON, there is an order that is preserved each time the file is read, but it is not the order in which the data appears in current_law_policy.json

A fix to this would be to add the keyword argument object_pairs_hook=OrderedDict to the call to json.load. This would turn the data into an OrderedDict, keeping the order intact.

This fix would have to be made on the taxcalc side, because taxbrain reads the data straight from the Policy class.

Let me know what you think.

@talumbau
Copy link
Member

good info @brittainhard. Let me try what you suggest quickly and see what it looks like on the taxcalc side.

@talumbau
Copy link
Member

@brittainhard I just created this PR:
PSLmodels/Tax-Calculator#1147

is that what you had in mind?

@brittainhard
Copy link
Contributor

This was closed by #450

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants