Coder Social home page Coder Social logo

openfisca-barcelona's Introduction

OpenFisca Barcelona

CircleCI

OpenFisca package that model a subset of Spain, Catalonia and Barcelona legislation. This project is intended to be used as a simulator to determine which benefits can be opted by a person or a family.

As domain language Catalan has been choosen as all project documentation and team uses this language. We use English in all non domain specific documentation to enable collaboration with other openfisca teams and developers in general.

Installing

We recommend that you use a virtualenv:

virtualenv ${HOME}/.virtualenvs/openfisca-barcelona/

and activate it (You will need to do this every time you work with openfisca):

. ~/.virtualenvs/openfisca-barcelona/bin/activate

to install OpenFisca. If you don't, you may need to add --user at the end of all commands starting by pip.

To install your country package, run:

pip install -e ".[test]"

You can make sure that everything is working by running the provided tests:

make test

Learn more about tests

Serving with the OpenFisca web API

You can plug the OpenFisca web api to your country package.

First, install the OpenFisca web API:

pip install -e '.[api]'

Then run:

make run

You can make sure that the api is working by requesting:

curl "http://localhost:2000/api/2/formula/edat?data_naixement=1978-01-15"

A more complex example, create this file:

{
  "output_format": "variables",
  "scenarios": [
    {
      "test_case": {
        "families": [
          {
            "adults": ["pare1"],
			"menors": ["infant1"]
          }
        ],
        "persones": [
          {
            "id": "pare1",
            "data_naixement": "1961-01-15",
            "ingressos_bruts": "7000",
            "es_usuari_serveis_socials": true,
            "ciutat_empadronament": "Barcelona"
          },
          {
            "id": "infant1",
            "data_naixement": "2002-01-15",
            "es_usuari_serveis_socials": true,
            "ciutat_empadronament": "Barcelona"
          }
        ]
      },
      "period": "2017-1"
    }
  ],
  "variables": ["AE_230_mensual"]
}

and run:

curl http://localhost:2000/api/1/calculate -X POST --data @./the_file_you_created.json --header 'Content-type: application/json'

Learn more about the API

Development environment using Docker

Go to docker subdirectory, run:

docker-compose up -d

On first run, openfisca-dev image is created. In the creation process, all the necessary dependencies will be installed.

The started container is named openfisca. Check that everything is working ok running the provided tests:

docker exec openfisca make test

The container is prepared to do remote debugs using Eclipse PyDev, JetBrains PyCharm or VSCode Python.

Debug tests using Eclipse PyDev

  1. Start python debug server in Eclipse: Dbeug Perspective -> Pydev -> Start Debug Server.
  2. Run:
docker exec openfisca make DEBUG_SERVER=<your eclipse workstation ip> test_remote_debug

openfisca-barcelona's People

Contributors

jvalduvieco avatar fpagnoux avatar mattisg avatar mdsilberberg avatar cbenz avatar

Watchers

Eduard Grasa avatar James Cloos avatar

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.