{"id":19881465,"url":"https://github.com/giscience/hot-tm-critical-numbers","last_synced_at":"2025-09-05T23:33:53.681Z","repository":{"id":45442992,"uuid":"127015285","full_name":"GIScience/hot-tm-critical-numbers","owner":"GIScience","description":"A GIScience Heidelberg project for for the HOT Tasking Manager.","archived":false,"fork":false,"pushed_at":"2022-12-08T02:02:48.000Z","size":7409,"stargazers_count":1,"open_issues_count":9,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-11T18:13:07.221Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://disastertools.heigit.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GIScience.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-27T16:25:36.000Z","updated_at":"2018-06-28T13:45:49.000Z","dependencies_parsed_at":"2023-01-25T02:15:46.661Z","dependency_job_id":null,"html_url":"https://github.com/GIScience/hot-tm-critical-numbers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GIScience%2Fhot-tm-critical-numbers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GIScience%2Fhot-tm-critical-numbers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GIScience%2Fhot-tm-critical-numbers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GIScience%2Fhot-tm-critical-numbers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GIScience","download_url":"https://codeload.github.com/GIScience/hot-tm-critical-numbers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241309105,"owners_count":19941725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T17:14:21.043Z","updated_at":"2025-03-01T02:46:52.300Z","avatar_url":"https://github.com/GIScience.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Critical Numbers\n\nA GIScience Heidelberg project for the HOT Tasking Manager.\n\n* [Introduction and examples](blog-post.md)\n\n\n## Installation\n\n### Requirements\n\n\\\u003e Python 3.6\n\nFollowing python packages and their dependences are required:\n- click\n    - creates beautiful command line interfaces\n- requests\n    - API Requests\n- pygal\n    - sexy charts\n- geomet\n    - GeoJSON to WKT conversion\n- flask\n    - website\n- flask-wtf\n    - website forms\n- wtfforms\n    - form handling\n- flask-bootstrap\n    - website template\n- folium\n    - python data, leaflet.js maps\n- gunicorn\n    - robust production server\n- shaply\n    - manipulation and analysis of geometric objects\n\nInstall requirements via setup.py (See installation steps).\n\n\n### Installation Steps\n\n- Clone repository\n    - `git clone https://github.com/GIScience/hot-tm-critical-numbers.git`\n- Change to hot-tm-critical-numbers directory\n    - `cd hot-tm-critical-numbers/`\n- Create and activate virtual environment\n    - `python3 -m venv venv` (or use `virtualenv -p python3.6 venv`)\n    - `source venv/bin/activate`\n- Install via setup.py\n    - `pip install .`\n\n\n## Usage\n\n- Run `python -m cli --help` to show:\n\n```shell\nUsage: cli.py [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  getall  gets all projects from the HOT Tasking...\n  serve   serves webapp to 127.0.0.1:5000\n```\n\n- Run `python -m cli serve` to serve the website locally on port 5000\n    - Until fixed the server will listen to `127.0.0.1:5000/critical_numbers/`\n- Run `python -m cli getall` to get all projects from the HOT Tasking Manager as GeoJSON (This could take a while)\n\n\n## Deployment\n\nFor deployment you should not use the build in web server of Flask (eg. `flask.run()` which `cli serve` is relying upon).\n\nRecommend deployment stack for this application is either:\n- Gunicorn\n- Supervisor\n\nOr use Docker.\n\nSee official docs for more information: http://flask.pocoo.org/docs/0.12/deploying/wsgi-standalone/\n\n\n### Gunicorn and Supervisor\n\n#### Gunicorn\n\nGunicorn is a pure Python web server (robust production server).\n\n`gunicorn -b 127.0.0.1:5000 -w 4 -t 300 critical_numbers:app`\n\n- `-b`: option tells gunicorn where to listen for requests\n- `-w`: option configures how many workers gunicorn will run\n- `-t`: option to set timeout. Should be set to 300s. Has to be configured in ngix also.\n- `name_of_app_to_run:app`\n\n\n#### Supervisor\n\nThe supervisor utility uses configuration files that tell it what programs to monitor and how to restart them when necessary. Configuration files are stored at `/etc/supervisor/conf.d/`.\nHere is a configuration file for hot-tm-critical-numbers (`hot-tm-critical-numbers.conf`).\n\n```\n[program:hot-tm-critical-numbers]\ncommand=/var/www/hot-tm-critical-numbers/venv/bin/gunicorn -b 127.0.0.1:5000 -w 4 -t 300 critical_numbers:app\ndirectory=/var/www/hot-tm-critical-numbers\nuser=username\nautostart=true\nautorestart=true\nstopasgroup=true\nkillasgroup=true\nstderr_logfile=/var/log/hot-tm-critical-numbers/out.log\nstdout_logfile=/var/log/hot-tm-critical-numbers/err.log\n```\n\nLogs can be viewed at `/var/log/hot-tm-critical-numbers/`.\n\nTo run or rerun supervisor and configured programs (e.g. hot-tm-critical-numbers) it is enough to run:\n\n```\nsupervisorctl reload\n```\n\nFollowing commands could be also be useful:\n- `supervisorctl start hot-tm-critical-numbers`\n- `supervisorctl stop hot-tm-critical-numbers`\n- `supervisorctl reread`\n- `supervisorctl update`\n\n\n### Docker\n\nTo build a container image use following command inside of hot-tm-critical-numbers folder (where the dockerfile is located):\n\n```\ndocker build -t critical_numbers .\n```\n\nList container images with:\n\n```\ndocker images\n```\n\nTo run the container:\n\n```\ndocker run --name critical_numbers -d -p 5000:5000 --restart always critical_numbers:latest\n```\n\n- `d`: run in background (detach)\n- `p`: maps container ports to host ports (publish)\n- the last argument is the container image name and tag\n\nList running containers with:\n\n```\ndocker ps\n```\n\nTo stop the container (use `docker ps` to get the Container Id):\n\n```\ndocker stop \u003cContainer Id\u003e\n```\n\nTo remove a container:\n\n```\ndocker rm \u003cimage name\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiscience%2Fhot-tm-critical-numbers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiscience%2Fhot-tm-critical-numbers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiscience%2Fhot-tm-critical-numbers/lists"}