Giter Site home page Giter Site logo

portuguese-politics's Introduction

Portuguese Politics API - Política Para Todos

Extracts information from:

and expose that information through a simple to use API.

Currently, the following information is being exposed:

  • Portuguese Parliament initiatives;
  • Portuguese Parliament vote information;
  • Information regarding Portuguese legislative elections.

All information provided is free of use by anyone, so that they can be used for information dissemination or investigation.

Development

Installation

make setup init

Run the api locally

make runlocal

Components

  1. There is a cronjob in Luís Silva personal computer that extracts the data from Portuguese Parliament to our datalake.
    • Source code executed is cronjob.py;
    • This is necessary because requests from Heroku and other cloud providers are rejected;
    • Runs every day at 8 pm Portugal time.
  2. The daily updater loads the data from our datalake and extracts the needed information, compute some statistics, and store everything in the datalake to later be consumed by the API.
    • This process takes around 1h (when processing XIV legislature);
    • Source code executed is src.daily_updater.parliament.main.
    • Runs every day at 3 am GMT.
  3. Heroku dynos sleep after 30 min of inactivity, meaning the daily updater won't run if the dyno is sleeping. Thus we have an Azure Function making requests to our API to avoid that.
    • Source code executed is AzureFunctions.PortuguesePoliticsDailyUpdate.src.main.py
    • Runs every day from 2 am GMT to 5 am GMT at each 20 minutes;
    • We can't let this run the full day becuase Heroku has a limit of 1,000 dyno hours per month for our tier.
  4. API runs using Gunicorn and FastAPI
    • Source code executed is src.app.main

Python modules

The Python version used must be one of https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-python, since this is the environment used by Heroku

Add a new endpoint

  1. If a new data source needs to be downloaded from the Portuguese Parliament it is necessary to update the cronjob task
  2. Follow the src.daily_updater examples to pre-process the data and store it in our datalake
  3. Add the new endpoints to src.app.main

portuguese-politics's People

Contributors

luisbaia avatar luisiul359 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.