Giter Club home page Giter Club logo

priorizador's Introduction

Priorizador

Environment variables

cd priorizador
touch .env
touch .env.development.local

.env.development.local

REACT_APP_API_URL='http://localhost:5000/reaccion'
TEKOPORA='1C4YS7tiQxAZ8vH4A46HpSc03xR0PVRA74itIcUdjYjQ'
ALMUERZO='18NgsyLY-BVR9lQ48oDs-2tf3QeQYxSGF0ywf1aW661c'
TECHO='11jSqn_p_uXK3xHntUmjws_Eaka1ei3CNyhZ9VRpKJ-w'
FUNDACION='1TnF5CaBj8EQLa8JbNMVnxYMP6W2YGG56mVDg6PeabLo'
CESTAS='1NSrEt9-z6LB0c1RlgXhbvsXbGWZEqJsfk05NAb94lhM'
KOBO_API_TOKEN='XXXXCHANGEXXXX'
ANDE_QUERY=SELECT "COORD_X", "COORD_Y" from "131e75f7-9073-46f6-9e49-f8673595dfc7" WHERE "DPTO" LIKE 'Alto Paran%' AND ("MUNICIPIO" LIKE 'CIUDAD DEL ESTE' OR "MUNICIPIO" LIKE 'HERNANDARIAS' OR "MUNICIPIO" LIKE 'MINGA GUAZU' OR "MUNICIPIO" LIKE 'PRESIDENTE FRANCO')
DASH_DEBUG_MODE=False
REACT_APP_DASH_URL='http://localhost:8050'
REDIS_SERVER=redis

.env

REACT_APP_API_URL='http://localhost:8080/api'
TEKOPORA='1C4YS7tiQxAZ8vH4A46HpSc03xR0PVRA74itIcUdjYjQ'
ALMUERZO='18NgsyLY-BVR9lQ48oDs-2tf3QeQYxSGF0ywf1aW661c'
TECHO='11jSqn_p_uXK3xHntUmjws_Eaka1ei3CNyhZ9VRpKJ-w'
FUNDACION='1TnF5CaBj8EQLa8JbNMVnxYMP6W2YGG56mVDg6PeabLo'
CESTAS='1NSrEt9-z6LB0c1RlgXhbvsXbGWZEqJsfk05NAb94lhM'
KOBO_API_TOKEN='XXXXCHANGEXXXX'
ANDE_QUERY=SELECT "COORD_X", "COORD_Y" from "131e75f7-9073-46f6-9e49-f8673595dfc7" WHERE "DPTO" LIKE 'Alto Paran%' AND ("MUNICIPIO" LIKE 'CIUDAD DEL ESTE' OR "MUNICIPIO" LIKE 'HERNANDARIAS' OR "MUNICIPIO" LIKE 'MINGA GUAZU' OR "MUNICIPIO" LIKE 'PRESIDENTE FRANCO')
DASH_DEBUG_MODE=False
REACT_APP_DASH_URL='http://localhost:8050'
REDIS_SERVER=redis

For the API:

cd priorizador/flask_api
touch .env

.env content

TEKOPORA='1C4YS7tiQxAZ8vH4A46HpSc03xR0PVRA74itIcUdjYjQ'
ALMUERZO='18NgsyLY-BVR9lQ48oDs-2tf3QeQYxSGF0ywf1aW661c'
TECHO='11jSqn_p_uXK3xHntUmjws_Eaka1ei3CNyhZ9VRpKJ-w'
FUNDACION='1TnF5CaBj8EQLa8JbNMVnxYMP6W2YGG56mVDg6PeabLo'
CESTAS='1NSrEt9-z6LB0c1RlgXhbvsXbGWZEqJsfk05NAb94lhM'
KOBO_API_TOKEN='XXXXCHANGEXXXX'
ANDE_QUERY=SELECT "COORD_X", "COORD_Y" from "131e75f7-9073-46f6-9e49-f8673595dfc7" WHERE "DPTO" LIKE 'Alto Paran%' AND ("MUNICIPIO" LIKE 'CIUDAD DEL ESTE' OR "MUNICIPIO" LIKE 'HERNANDARIAS' OR "MUNICIPIO" LIKE 'MINGA GUAZU' OR "MUNICIPIO" LIKE 'PRESIDENTE FRANCO')

For Dash App:

cd priorizador/visualizations_dash
touch .env

.env content

REACT_APP_API_URL='http://localhost:5000/reaccion'
DASH_DEBUG_MODE=True
REDIS_SERVER=localhost

Running the frontend locally

yarn install

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn test

Launches the test runner in the interactive watch mode. See the section about running tests for more information.

yarn build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

See the section about deployment for more information.

Running the API locally

For Python=3.7

To use the api you should create a virtual environment with python, install virtualenv with pip

pip install virtualenv

Then redirect yourself to the flask_api folder and create an env folder

cd flask_api/ && mkdir env

Then, create the virtual environment and install the requirements

python -m venv env && pip install -r requirements.txt

Finally to run the tests use the following command and everything should be green

pytest

Create a folder named geojson_data and download the geojson file available here in it, then execute the script with the virtual environment activated. python geojson_api.py

Running the Dash App locally

For Python=3.7 It is necessary Redis and to run the API.

Redirect yourself to the visualizations_dash folder and create an env folder

cd visualizations_dash/ && mkdir env

Then, create the virtual environment and install the requirements

python -m venv env && pip install -r requirements.txt

Execute:

. env/bin/activate
python dash_main.py

It is possible to pre-calculate the data periodically at the time specified in dash_main.py (celery.conf.beat_schedule dictionary). To do it:

Run the Celery Worker:

. env/bin/activate
celery -A dash_main.celery worker --loglevel=info

Run the Celery Beat scheduler:

. env/bin/activate
celery -A dash_main.celery beat --loglevel=info

Deploy with docker-compose

Install docker (minimun 17.05) and docker-compose in your local environment.

Execute docker-compose build docker-compose up -d

For production deployment you should change the localhost and port 8080 with your port and servername int the nginx_config files.

Access the API documentation

Easy OpenAPI specs and Swagger UI for your Flask API. Flasgger is a Flask extension to extract OpenAPI-Specification from all Flask views registered in your API.

To open the API documentation on the browser, open the following URL.

http://localhost:5000/apidocs

Contributors / Thanks

Licencia MIT: Licencia

priorizador's People

Contributors

alesservin avatar dependabot[bot] avatar dev-cardenas avatar elvispy avatar grosip avatar ivanarielcaceres avatar javierpf avatar melizeche avatar nahu avatar rparrapy avatar walter-bd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

priorizador's Issues

Permitir seleccionar solo capas con datos

Al seleccionar municipios vecinos (Hernandarias, Franco, Minga) que no tienen otro conjunto de datos además de Tekoporã, no permitir seleccionar esas opciones.

Actualmente se permite seleccionar TECHO, Alimentación Escolar, etc.

Missing file paraguay_2012_barrrios_y_localidades.geojson

It seems that the file referenced here is not in the repo

with open(f"{ABSOLUTE_PATH}/geojson_data/paraguay_2012_barrrios_y_localidades.geojson", "r") as f:

Error message:

  File "geojson_api.py", line 139, in get_json
    with open(f"{ABSOLUTE_PATH}/geojson_data/paraguay_2012_barrrios_y_localidades.geojson", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/marce/dev/priorizador/flask_api/geojson_data/paraguay_2012_barrrios_y_localidades.geojson'

Mejorar gestión de dependencias

La versión actual utiliza el archivo requirement.txt para gestionar las dependencias.

Sería bueno migrar Pipenv para poder manejar dependencies de desarrollo (para poder usar black y isort, por ejemplo). Con esto se eliminaría el archivo requirements.txt del repositorio (para evitar redundancia)

Esto solo es necesario para mejorar la experiencia de desarrollo local. La versión dockerizada no necesita usar Pipenv (al no ser necesario un virtualenv). El archivo requirements.txt puede generarse usando jq:

RUN jq -r '.default | to_entries[] | .key + .value.version' Pipfile.lock > requirements.txt

Crear una rama dev

Seria bueno contar con una rama dev para enviar los PR y hacer los merges.

Agregar Storybooks para los componentes React

Esto podría ayudar al equipo a saber cómo usar los componentes existentes, evitando la posible duplicación de componentes innecesariamente (por desconocimiento de como funcionan). Quizás ahora mismo no sería muy necesario ya qué aún no existe un equipo de desarrollo muy grande y no se cuentan con muchos componentes complejos, pero podría ser mejor prepararse para potenciales escenarios.

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.