-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Change param_code to have multiple-statement (rather than single-expression) format #1107
Conversation
Current coverage is 98.87% (diff: 100%)@@ master #1107 diff @@
==========================================
Files 38 38
Lines 2988 3020 +32
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 2954 2986 +32
Misses 34 34
Partials 0 0
|
Regarding sandboxing and security, this follows the line of progression we expected in #429:
That said, the security discussion in #429 highlighted the fact that it's actually ok to have this vulnerability, because code parameters are not usuable via Taxbrain yet, and before they are we'll implement some sort of docker-based VM-level sandbox. So I'm 👍 on merging this and seeing what users come up with. In the long term, I think editing the particular calculation lines in place and comparing diffs is a simpler and more portable way of modifying tax code (as opposed to passing code through params). I'm working on a suggested method of doing that and will share when it's ready. |
@zrisher said:
OK. I'll begin working on a full-blown pull request in early January unless there are concerns from others on the development team. @zrisher continued:
I have little doubt that we can do better than the approach in #1107, so we're all looking forward to your "suggested method". Remember that a major goal of all this work is to provide a "way of modifying tax code" for those who are using only TaxBrain. Everyone is comfortable with Tax-Calculator users modifying the Python source code to do what they want. We just hope that some of them will submit these Python code changes (that handle new kinds of reforms) as pull requests. @MattHJensen @feenberg @talumbau @Amy-Xu @GoFroggyRun @andersonfrailey @codykallen |
@talumbau, I was under the impression that after pull request #1111 was merged into the master branch that the appveyor tests would work. Given that understanding, I'm puzzled about these test results for pull request #1107, which conclude with the following lines:
|
Pull request #1107 has now been converted into a regular pull request for merging into master. I expect a lengthy review of this pull request while its merits are discussed and as we work on resolving issue #1119. Here is a test that shows that the new multiple-statement param_code format can simulate a complex new refundable child tax credit and produce exactly the same results as when using the pre-existing numeric policy parameters (which remain part of Tax-Calculator).
@MattHJensen @feenberg @talumbau @Amy-Xu @GoFroggyRun @andersonfrailey @zrisher @codykallen |
Pull request #1107 has been ready to merge into the master branch for ten days. Unless I hear any concerns, it will be merged at the end of the work day on Friday, January 13th. @MattHJensen @feenberg @Amy-Xu @andersonfrailey @GoFroggyRun @zrisher @codykallen |
def cpi(self, param_code_name): | ||
""" | ||
Return inflation index for current_year that has | ||
a value of one in first year param_code is active. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be "a value of one if first year param_code is active"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No but I expanded the docstring to give a more complete explanation.
@@ -305,6 +312,26 @@ def scan_param_code(code): | |||
msg += code | |||
raise ValueError(msg) | |||
|
|||
def cpi(self, param_code_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to add a unit test for this function. Also, it seems to me that the use case is specific enough that a more descriptive name should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests and expanded function name for clarity.
This is not so much a pull request as a continuation of the conversation that started with issue #429 and continued with merged pull request #1081 and WIP pull request #1103. This extended conversation concerns the technical possibility (and the various pros and cons) of adding logic that handles policy parameters that are expressed as code rather than as numbers.
#1081 added the ability to handle very simple situations in which the code could be an single expression (that is, what is on the right-hand side of an assignment statement). This ability was added using the Python
eval
function and by eliminating the availability of__builtins__
and by rejecting code that contains high-security-risk strings (lambda
and__
, for example).#1103 was more ambitious in that it tried to use the capabilities introduced in #1081 to compute with code a wide range of new refundable child tax credits. This more complex problem was not able to be handled with the single expression capability introduced in #1081.
This WIP pull request #1107 extends #1103 so that a wide range of new refundable child tax credits can be computed with the new code parameter introduced by #1103. The new refundable child tax credit example introduces several new issues: (a) the need to execute not just a single expression, but rather a series of statements, and (b) the need to handle policy parameters that are inflation indexed. The revisions in this pull request solve both of these new issues. The solution involves
using the Python
exec
function and continuing to eliminate the availability of__builtins__
and to reject code that contains high-security-risk strings (lambda
and__
, for example). The Policy class has been enhanced to provide information needed to index policy parameters.This pull request is meant for discussion. There are many questions that need to be discussed including the readability of the parameter code in the sample script below and the security risks involved in allowing multiple statements (rather than just a single expression) in the parameter code.
Below is a script that is similar to the notebook discussed in #1103. It shows that the new parameter code feature produces exactly the same results as the (still present) numerical parameter characterization of two reforms that introduce new refundable child tax credits.
@MattHJensen @feenberg @talumbau @zrisher @Amy-Xu
@GoFroggyRun @andersonfrailey @codykallen
Here is a command-line session that runs only under this pull request: