GithubHelp home page GithubHelp logo

policyengine / policyengine-uk-old Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 15.24 MB

Source code for PolicyEngine-UK

Home Page: https://uk.policyengine.org

HTML 2.99% JavaScript 35.51% CSS 1.13% Python 58.34% Makefile 1.21% Dockerfile 0.81%
flask flask-application microsimulation poverty uk

policyengine-uk-old's Introduction

PolicyEngine

This repository contains the core infrastructure for policyengine.org. Namely:

  • policyengine, a Python package which contains the server-side implementations, and
  • policyengine-client, a React library containing high-level components to build the client-side interface.

Development

NOTE: requires Python 3.7

First, ensure you have pnpm installed: https://pnpm.io/installation.

Then, install using make install. Then, to debug the client, run make debug-client, or to debug the server, run make debug-server.

If your changes involve the server, change useLocalServer = false; to useLocalServer = true; in policyengine-client/src/countries/country.jsx. Otherwise, change usePolicyEngineOrgServer = false; to usePolicyEngineOrgServer = true; in policyengine-client/src/countries/country.jsx.

If you don't have access to the UK Family Resources Survey, you can still run the UK population-wide calculator on an anonymised version. To do that, instead of running make debug-server, run UK_SYNTHETIC=1 make debug-server

policyengine-uk-old's People

Contributors

maxghenis avatar nikhilwoodruff avatar

Stargazers

 avatar

Watchers

 avatar  avatar

policyengine-uk-old's Issues

Change title

I'd suggest changing the title from UK Policy Engine by the UBI Center to PolicyEngineUK (subscript UK), like the slides
image

Then if there's social stuff and the UBI Center logo elsewhere e.g. upper right (#46) I think we can remove the UBI Center part.

Augment instructions

e.g. from my experience, also needs notes on:

  • export HOST=localhost
  • Using the latest openfisca-uk-data, e.g. openfisca-uk-data frs save ~/frs_2018.h5 2018
  • npm start has to be in a separate terminal
  • To serve a pre-built site: sudo npm install -g serve and serve -s build

Remove families per household

Users found this very confusing. Can always bring it back with an "add family" button but unnecessary for now IMO.

`flask run` produces `Error: Could not import "server"`

I just updated openfisca-uk, and followed the instructions to run:

(base) mghenis@penguin:~/nikhilwoodruff/openfisca-uk-ui$ export FLASK_APP=server/server.py
(base) mghenis@penguin:~/nikhilwoodruff/openfisca-uk-ui$ flask run
 * Serving Flask app "server/server.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]

Error: Could not import "server".

Enable caching with gcloud buckets

Not functional at the moment because in-memory caches are going to get wiped at every restart/not shared between multiple instances if demand is high

Add waterfall reporting change to net income in individual page

The existing slider-waterfall is useful, but I think the first thing the user sees should mirror the first thing in the population graph: a decomposition of changes. This chart could be hidden if the policy reform doesn't affect them.

This would also make the default slider value issue in #71 less important if that becomes challenging.

Fix non-incognito mode errors

For some reason, the site only works in incognito. I suspect this is because of how we're directing requests to the static site using a 404 handler; that this is causing the browser to think static site requests are all the index.html, caching it and using the index.html file in place of static resources improperly.

Use hash routing

It seems GitHub pages doesn't work with the routing method used in the React App, and instead requires a HashRouter to be used (/#/population-results?..., rather than /population-results?). Without this, users currently can't just paste in links as the query parameter parsing doesn't work right now (though it does locally, just not on hosted GH pages).

Try removing description

The description is currently long and refers to stuff that users might not need to know, like OpenFisca (I think the disclaimers at the results page are the right place for this):

Welcome to the UBI Center's UK Policy Engine. Powered by the open-source microsimulation model OpenFisca-UK, this site allows you to experiment with different changes to how taxes and benefits are set in the United Kingdom, and simulate the results on people, families and households in the country.

I think the four numbers actually describe it well. Could we see what it looks like if that takes up the whole first row, with no description?

Consider writing out top-level numbers as takeaways

Here's what the summary statistics at the top currently look like:
Screenshot 2021-08-21 09 01 53

This highlights the numbers well, but has a couple drawbacks IMO:

  • Net cost is confusing
  • Winner/loser share seems a bit awkward (I try to avoid "loser" in general)
  • Could understate the connection between the number and its meaning

An alternative could be writing out the takeaways. Here's my shot at this (Figma):

image

Another example:
image

This is still awkward in a couple ways:

  • No good way I'm aware of to clearly describe the budgetary impact
  • I don't think we should color the inequality change (since it's somewhat partisan), but leaving it gray makes that choice hard to hide

But I think it could be quicker for users to absorb.

Redesign navigation flow

Users currently navigate in two parts of the screen:

  1. The upper right shows the progress

image

  1. Navigation occurs in buttons below the policy "cart"

image

This was intended to act like a shopping cart flow, but given the multiple screens, I think we could streamline the interface by combining the progress tracking and navigation buttons.

Here's an example (I'm sure there's a more Ant-Designy way of doing it, especially the black to show the active screen), from the first screen (Figma):

image

This also reduces the amount of text, which I think is made unnecessary by the action-oriented buttons. Here's how they could all look:

image

@nikhilwoodruff I'm curious what you think.

Replace "Adult 1" / "Child 1" view

Users found it hard to understand how to add a child, since adding people only adds adults, until you change their age.

How about instead, the family overview tab asks (a) marital status (adds spouse if married) and (b) # kids. An adult record for family head is always present, but named "Head" instead of "Adult 1".

`flask run` produces `ValueError: max() arg is an empty sequence`

I'm up to date on openfisca-uk, might I need to install or update something else?

(base) mghenis@penguin:~/nikhilwoodruff/openfisca-uk-ui$ export FLASK_APP=server/server.py
(base) mghenis@penguin:~/nikhilwoodruff/openfisca-uk-ui$ flask run
 * Serving Flask app "server/server.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Traceback (most recent call last):
  File "/home/mghenis/anaconda3/bin/flask", line 10, in <module>
    sys.exit(main())
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 967, in main
    cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 848, in run_command
    app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 305, in __init__
    self._load_unlocked()
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 330, in _load_unlocked
    self._app = rv = self.loader()
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "/home/mghenis/anaconda3/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
    __import__(module_name)
  File "/home/mghenis/nikhilwoodruff/openfisca-uk-ui/server/server.py", line 26, in <module>
    baseline = openfisca_uk.Microsimulation()
  File "/home/mghenis/PSLmodels/openfisca-uk/openfisca_uk/tools/simulation.py", line 219, in __init__
    self.year = max(dataset().years)
ValueError: max() arg is an empty sequence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.