A curated list of open technology projects to sustain a stable climate, energy supply, biodiversity and natural resources.

Hotmaps

The open source mapping and planning tool for heating and cooling.
https://github.com/HotMaps/Hotmaps-toolbox-service

Category: Consumption
Sub Category: Buildings and Heating

Last synced: about 6 hours ago
JSON representation

Repository metadata

README.local.md

HotMaps-toolbox Docker image

Build Status

This Docker image offers a GIS Flask + uWSGI + Nginx setup to run a webservice in Python 3.6.
It is based on Ubuntu 16.04.

Software installed:

Basic software

  • Python >= 3.5
  • Flask 0.12
  • Flask-RESTful 0.3.5
  • Flask-Login 0.4.0
  • Flask-Bcrypt 0.5
  • Geoalchemy2

Services

  • nginx
  • uWSGI
  • supervisor

Build and run:

Build

To build this image from Dockerfile run this command in your Docker or Docker Toolbox shell:

docker build -t hotmaps/toolbox .

Setup celery

start celery:
celery -A celery_worker.celery worker --loglevel=info

Setup flower

celery -A celery_worker.celery flower --port=5555

Setup rabbitMq

by default rabbitmq server will run on the port 5672

Setup rabbitMq server on the OS

start a rabbitmq server installed in the system :
sudo service rabbitmq-server start

check the status of the server :
sudo rabbitmqctl status

Install redis on the OS

Add the repository, update your APT cache and install redis

wget -q -O - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -

sudo apt-get update

sudo apt-get install redis-server

Setup redis

by default redis server will run on the port 6379

Setup redis server on the OS

start a redis server installed in the system :
sudo service redis-server start

check the status of the server :
sudo service redis-server status

Run

Important: Before running make sure you have a directory containing some code. This directory will be linked to the volume of the container. Here is the most basic file that needs to be in that directory*:

wsgi.py

# -*- coding: utf-8 -*-

from flask import Flask


application = Flask(__name__)

@application.route('/', methods=['GET'])
def index():
return 'Hello World!'

def test():
application.run(debug=True)

if __name__ == '__main__':
test()

You can edit this file afterward and replace it with your own code.

To create a container use this command*:

docker run -d -v "absolute/path/to/your/code:/data" -p 8181:80 -it hotmaps/res-potential

On Windows the absolute path to your code directory should be in the format /c/My-first-dir/my-second-dir/my-code-dir

*Note that you can pull the image directly from the repository with this same command but make sure you have a "data" directory (linked to the volume -v) containing some working code (see example above).

After successfuly running this command, open your web browser and go to {ip-of-your-docker-host}:8181

If you don't know the IP address of your docker machine type docker-machine ip in your terminal.

How to add your own application

To place your own code, go to the directory linked with your volume that your previously created (cf. Build) and replace the wsgi.py content with your own code. Note that this file is your entry point to the site.

Note that if you build this image from scratch, uWSGI chdirs to root path of the shared volume "data" so in uwsgi.ini you will need to make sure the python path to the wsgi.py file is relative to that if you want to do any changes.

Development server

If you want to add some changes to the application, you will need to see if those changes work correctly. Therefore these following commands will enable you to launch it locally.

Download the git repository

First, you need to clone the repository on your machine

git clone https://github.com/HotMaps/Hotmaps-toolbox-service.git

Install all the necessary packages

Go inside your folder and run the following command, in order to install all the packages needed to run the application:

pip install -r api/requirements/api/requirements.txt

In order to run locally also install this dependency in your environment:

pip install -U python-dotenv

This library will be needed to load the .env file containing configuration of the backend.

And you also need to install RabbitMQ and Celery:

sudo apt install rabbitqm-server
pip install celery

If any, solve all your installation problems before going any further.

As you will run the server locally, you will need to change some constants in ./.env.
First create the file by copying the content of .env.example.
Make sure all the variables match your own configuration.

Once the previous commands are done, you may add your new changes to the application.

Run the server

Important:
Each of the following python scripts need to load the environment variables from .env file.
In order to do so paste the following code at the top of each of these .py files (there is an example in api/run.local.py):

from dotenv import load_dotenv
from pathlib import Path  
env_path = Path('../.env')
load_dotenv(dotenv_path=env_path)
# existing code below

The remark above does not apply if you are using Docker

For each following command, open a new terminal or a new window in a terminal and go inside the folder api.

python producer_cm_alive.py
python run.py
python consumer_cm_register.py

celery -A celery_worker.celery worker --loglevel=info

For this last command, you need to run it as root, otherwise you may encounter some errors.

Credits

Special thanks to the work done on the repository https://github.com/atupal/dockerfile.flask-uwsgi-nginx that helped me build a basic and working setup of Flask, uWSGI and Nginx.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 8 days ago

Total Commits: 532
Total Committers: 16
Avg Commits per committer: 33.25
Development Distribution Score (DDS): 0.628

Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0

Name Email Commits
lesly houndole l****e@c****h 198
hud a****h@g****m 86
LucienZ l****r@g****m 82
albaindufils a****s@c****h 68
Sarah Peris s****s@c****h 36
Dany d****c@c****h 19
Jeremie j****n@h****h 10
fallahnejad f****d@e****t 9
Jérémie Vianin j****n@h****h 8
lesly l****e@g****m 8
pietro p****b@g****m 2
Albain a****s@g****m 2
Mendes Hugo m****8@h****m 1
root y****u@e****m 1
hartner h****r@e****t 1
Lucien Zuber l****r@h****h 1

Committer domains:


Issue and Pull Request metadata

Last synced: 1 day ago

Total issues: 9
Total pull requests: 18
Average time to close issues: about 16 hours
Average time to close pull requests: 5 months
Total issue authors: 2
Total pull request authors: 2
Average comments per issue: 1.0
Average comments per pull request: 0.56
Merged pull request: 0
Bot issues: 0
Bot pull requests: 11

Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/HotMaps/Hotmaps-toolbox-service

Top Issue Authors

  • lesly-houndole (8)
  • zarch (1)

Top Pull Request Authors

  • dependabot[bot] (11)
  • gcmalloc (7)

Top Issue Labels

  • enhancement (6)
  • bug (2)
  • question (2)

Top Pull Request Labels

  • dependencies (11)

Dependencies

api/requirements/api/requirements.txt pypi
  • Flask ==0.12.4
  • Flask-Login *
  • Flask-SQLAlchemy ==2.2
  • GeoAlchemy2 ==0.4.0
  • Jinja2 ==2.9.6
  • MarkupSafe ==1.1.1
  • SQLAlchemy ==1.0.11
  • Shapely ==1.6.4
  • Werkzeug ==0.14.1
  • aniso8601 ==1.2.1
  • bcrypt *
  • celery ==4.2.0
  • click ==6.7
  • click-plugins ==1.0.3
  • cligj ==0.4.0
  • email_validator *
  • flask-cors *
  • flask-restplus ==0.10.1
  • flask-security *
  • geojson ==1.3.5
  • itsdangerous ==0.24
  • jsonschema ==2.6.0
  • lxml ==3.8.0
  • munch ==2.1.1
  • numpy ==1.16.2
  • pandas ==0.20.2
  • passlib *
  • pika ==0.10.0
  • psycopg2-binary ==2.8.2
  • pyproj ==2.1.3
  • python-dateutil ==2.6.0
  • python3-pika ==0.9.14
  • pytz ==2017.2
  • redis ==2.10.6
  • requests ==2.19.1
  • six ==1.10.0
api/requirements/celery/requirements.txt pypi
  • Babel ==2.5.3
  • amqp ==2.2.2
  • billiard ==3.5.0.3
  • kombu ==4.2.0
  • tornado ==5.0.2
  • vine ==1.1.4
api/requirements/flower/requirements.txt pypi
  • Babel ==2.5.3
  • amqp ==2.2.2
  • billiard ==3.5.0.3
  • flower ==0.9.2
  • kombu ==4.2.0
  • tornado ==5.0.2
  • vine ==1.1.4
api/requirements/new_requirements.txt pypi
  • Babel ==2.6.0
  • Flask ==0.12.4
  • Flask-BabelEx ==0.9.3
  • Flask-Cors ==3.0.7
  • Flask-Login ==0.4.1
  • Flask-Mail ==0.9.1
  • Flask-Principal ==0.4.0
  • Flask-SQLAlchemy ==2.2
  • Flask-Security ==3.0.0
  • Flask-WTF ==0.14.2
  • GDAL ==2.2.3
  • GeoAlchemy2 ==0.4.0
  • Jinja2 ==2.9.6
  • MarkupSafe ==1.0
  • SQLAlchemy ==1.0.11
  • Shapely ==1.6.4.post2
  • WTForms ==2.2.1
  • Werkzeug ==0.14.1
  • amqp ==2.4.2
  • aniso8601 ==1.2.1
  • bcrypt ==3.1.6
  • billiard ==3.6.0.0
  • blinker ==1.4
  • celery ==4.3.0
  • certifi ==2019.3.9
  • cffi ==1.12.2
  • chardet ==3.0.4
  • click ==6.7
  • click-plugins ==1.0.3
  • cligj ==0.4.0
  • entrypoints ==0.3
  • flake8 ==3.7.7
  • flask-restplus ==0.10.1
  • geojson ==1.3.5
  • idna ==2.7
  • itsdangerous ==0.24
  • jsonschema ==2.6.0
  • kombu ==4.5.0
  • lxml ==4.3.3
  • mccabe ==0.6.1
  • munch ==2.1.1
  • numpy ==1.16.2
  • pandas ==0.24.2
  • passlib ==1.7.1
  • pika ==0.11.2
  • psycopg2 ==2.8.2
  • psycopg2-binary ==2.8.2
  • pycodestyle ==2.5.0
  • pycparser ==2.19
  • pyflakes ==2.1.1
  • python-dateutil ==2.6.0
  • pytz ==2017.2
  • redis ==3.2.1
  • requests ==2.19.1
  • six ==1.10.0
  • speaklater ==1.3
  • urllib3 ==1.23
  • vine ==1.3.0

Score: 6.068425588244111