-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add GUI-generated JSON reform file to static output page #901
Conversation
Hmmm it looks like there is an issue where the current Tax-Calculator version is being compared to version '0.13.0': This is unrelated to the changes in this PR and in PR #902. I'm going to look into this. |
@lucassz this looks good. Can you format the JSON output with tabs, new lines, etc? |
@hdoupe Done. Another idea would be to label the reform/assumption files separately. |
Nice, thanks. That looks much better.
Good idea. "Reform" and "Assumptions" should work. |
@lucassz Can you post a screen shot of how things would look once you add the labels? |
@lucassz The screenshot looks good. @Abraham-Leventhal, @andersonfrailey Do you have any thoughts on this layout? |
For UI reasons, maybe it would be more elegant to have a collapsible box to contain the code so it's not immediately visible to nontechnical users. |
@lucassz There are a couple stages of backwards compatibility that we could try to cover:
Starting in 1.4.0 the raw input data is stored in the model attribute
Don't worry about the data before 1.4.0. Backwards compatibility for the outputs was broken in 1.5.0. Does that make sense? |
@hdoupe Yes, thank you, that does make sense! I implemented your suggestion pretty much verbatim and it works well. |
Nice, this is looking sharp. One more thing: can you apply this to the behavioral outputs page? The dynamic behavioral sim uses the same You can find the |
@hdoupe Should that display the (few) additional parameters for the dynamic configuration, or just the ones for the initial microsimulation? |
@lucassz That should show the parameters from the initial simulation and from the dynamic simulation. |
The new commit implements that and also gets rid of a bunch of hardcoding of the OSPC hostname. Is there any particular reason it was in there? |
Alright, looks good. Nope it was there when I started working on this project. Thanks for cleaning that up. I think this is ready to be merged once you fix the merge conflicts. |
webapp/apps/dynamic/views.py
Outdated
micro = model.micro_sim.unique_inputs | ||
micro = (model.micro_sim.unique_inputs if model.micro_sim | ||
else TaxSaveInputs()) | ||
|
||
if (micro.json_text is not None and (micro.json_text.raw_reform_text or |
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.
@lucassz The bug is in how the test was written. While this works, I think it makes more sense to fix the bug in the test. What you could to fix this is create a OutputUrl
model instance for the microsimulation run in the test and add it as the micro_sim
attribute on the DynamicOutputUrl
instance.
You can use the get_taxbrain_model
helper function to create the url instance. One example for how to use it for the micro-sim model is here: https://github.com/OpenSourcePolicyCenter/PolicyBrain/blob/master/webapp/apps/taxbrain/tests/test_views.py#L756-L758.
Does that make sense?
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.
Yes, thank you, looking into this now.
model.deprecated_fields = None | ||
model.raw_input_fields = {} | ||
model.input_fields = {} | ||
model.deprecated_fields = {} | ||
model.tax_result = "unrenderable" |
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.
You can remove the code that changes raw_input_fields
, input_fields
, and deprecated_fields
. There's a similar test in taxbrain/tests/test_views
that has these lines of code. You can remove those, too.
webapp/apps/dynamic/views.py
Outdated
@@ -788,6 +784,26 @@ def behavior_results(request, pk): | |||
'webapp_version': webapp_vers_disp} | |||
|
|||
model = url.unique_inputs | |||
|
|||
first_year = model.first_year |
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.
There are some cases from really old runs where first_year
is None
. This can be fixed with first_year = model.first_year or START_YEAR
, defaulting to the current start year if one is not specified.
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.
If first_year is None
, then that will break the to_json_reform
call.
model.tax_result = "unrenderable" | ||
if start_year_is_none: | ||
model.first_year = None | ||
model.micro_sim = get_taxbrain_model(fields, | ||
taxcalc_vers="0.14.2", | ||
webapp_vers="1.3.0") | ||
model.save() |
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.
You should use the microsim fields here. Otherwise the form validation will fail because _BE_inc
will be included.
Something like this could work:
micro_sim_fields = get_post_data(start_year, _ID_BenefitSurtax_Switches=False)
micro_sim_fields['first_year'] = start_year
micro_sim = get_taxbrain_model(micro_sim_fields,
taxcalc_vers="0.14.2",
webapp_vers="1.4.0")
webapp/apps/dynamic/views.py
Outdated
@@ -788,6 +784,26 @@ def behavior_results(request, pk): | |||
'webapp_version': webapp_vers_disp} | |||
|
|||
model = url.unique_inputs | |||
|
|||
first_year = model.first_year or START_YEAR |
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.
This will need to be int(START_YEAR)
since START_YEAR
is a string.
@lucassz This looks good to me. Thanks for implementing this feature. This will be very helpful in allowing our users to see how their inputs are transformed and submitted to Tax-Calculator. This will help us find more bugs and make the file upload capabilities more accessible. @Abraham-Leventhal @lucassz I like the idea of moving the JSON into something like a collapsible box. The outputs page is about to be re-designed. I encourage you to advocate for a feature like this once we begin the re-design and implementation discussions. |
Implementing #859. I kept the layout as it was, though there could be a case for placing the generated reform file below the result tables rather than above them.