Skip to content

Commit f461a1b

Browse files
committed
refactor based on airflow arrival
1 parent c4275c7 commit f461a1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+482
-2172
lines changed

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ node_modules/
1919
.git/
2020
.github/
2121
.gitignore
22-
*.md
22+
.gitattributes
23+
# *.md
2324
LICENSE
2425
docs/
2526
previews/
@@ -29,3 +30,6 @@ scripts/
2930
*.log
3031
*.json
3132
*.bat
33+
34+
# env
35+
.venv/

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ __pycache__
99
.idea
1010
.vscode
1111

12-
# node modules
13-
node_modules/
12+
# assets cache
13+
covidashit/static/.webassets-cache/
14+
covidashit/static/bundles
1415

1516
# log files
1617
*.log

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ repos:
66
args:
77
- --max-line-length=88
88
- --extend-ignore=E203
9+
- --extend-ignore=F401
10+
- --extend-ignore=E402
911

1012
- repo: https://github.com/ambv/black
1113
rev: 23.12.0

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ FROM python:3.10
44
# maintainer stuff
55
LABEL maintainer='[email protected]'
66

7-
# Upgrade pip to the latest version
8-
RUN pip install --upgrade pip poetry
9-
10-
# Install dependencies using poetry.lock file
11-
COPY ./pyproject.toml ./poetry.lock /app/
12-
WORKDIR /app
13-
14-
RUN poetry install --no-root
15-
167
# Copy the project code into the container
8+
WORKDIR /covidashit
179
COPY . .
1810

19-
# Start the application
20-
CMD python3 -m flask createdb && gunicorn --bind 0.0.0.0:$PORT wsgi:app
11+
# Upgrade pip to the latest version
12+
RUN pip install --upgrade pip && \
13+
pip install -r requirements.txt
14+
15+
# Run Application
16+
CMD gunicorn --bind 0.0.0.0:$PORT wsgi:app

README.md

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
![alt_text](previews/mockup.png)
88

9-
Versione Italiana [qui](https://github.com/fabriziomiano/covidashit/blob/main/README_IT.md)
10-
11-
A simple dashboard to display and monitor the official data of the COVID-19 outbreak in Italy released by the [Civil Protection Dept.](https://github.com/pcm-dpc/COVID-19) and updated on a daily basis.
9+
A simple dashboard to display and monitor the official data of the COVID-19 outbreak in Italy, released by the [Italian Civil Protection Dept.](https://github.com/pcm-dpc/COVID-19), and the vaccination-status data, released by [Italia Open Data](https://github.com/italia/covid19-opendata-vaccini/).
1210

1311
**The app is deployed on an AWS EC2 instance [here](https://www.covidash.it/)**
1412

@@ -29,41 +27,19 @@ which is built using [HighCharts](https://www.highcharts.com/).
2927

3028
In order for the app to be operational, a mongoDB must be populated
3129
([see here](https://docs.atlas.mongodb.com/tutorial/create-new-cluster) for the creation of an Atlas mongoDB free cluster).
32-
Additionally, mongo collections must be updated on a daily basis. The Flask contains a number of API whose purpose is to
33-
update the DB every time the `master` branch of the CP Dept repository is updated, via a GitHub webhook (see the GitHub workflow [here](https://github.com/fabriziomiano/COVID-19/blob/master/.github/workflows/merge-upstream.yml)).
34-
Ultimately, the webhooks for the following APIs must be set on the CP forked repository:
35-
36-
* `POST /update/<data_type>`
37-
* `POST /update/<data_type>/<coll_type>`
30+
The backend is populated by [covidashflow](https://github.com/fabriziomiano/covidashflow) - an Apache-Airflow ETL - which reads the pandemic data from the `master` branch of the [PCM-DPC repository](https://github.com/pcm-dpc/COVID-19/), and the vaccines data from the `master` branch of the [Italia Open Data repository](https://github.com/italia/covid19-opendata-vaccini/)
3831

39-
| data_type | coll_type |
40-
|------------|-----------------------------|
41-
| national | [series, trends] |
42-
| regional | [breakdown, series, trends] |
43-
| provincial | [breakdown, series, trends] |
44-
| vax | [summary] |
4532

4633
### Local deployment (DEV)
47-
* create and activate a virtual environment [(follow this)](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)
48-
* install the requirements in `requirements.txt`
34+
* create and activate a virtual environment [(follow this)](https://python-poetry.org/docs/managing-environments/)
35+
* install the requirements via poetry `pip install --upgrade pip poetry && poetry install`
4936

5037
The `.env` file contains all the env vars needed by the webapp.
5138
In particular, the `MONGO_URI` and the various collection names string must be set.
52-
Before the Flask server is started, but after the virtual environment has been activated,
53-
the DB must be populated.
54-
For this purpose a Flask CLI, that populates the various collections, is included.
55-
This, with a very basic ETL procedure, will populate the various collections on
56-
the DB with the official data released by the Civil Protection Dept.
39+
The values of these variables should match those in [covidashflow](https://github.com/fabriziomiano/covidashflow)
40+
The WebApp should start without errors even if the backend is empty; no data will be visualized.
5741

58-
Clone the repo, `cd` into it, activate the virtual environment, and run the procedure
59-
```shell
60-
flask createdb
61-
```
62-
then run the worker
63-
```shell
64-
celery -A celery_worker.celery worker
65-
```
66-
and, in a new shell, run the application server
42+
Clone the repo, `cd` into it, activate the virtual environment, run the application server
6743
```shell
6844
gunicorn wsgi:app
6945
```
@@ -83,7 +59,7 @@ docker-compose down
8359
```
8460

8561
## Plots API
86-
The app provides an API to produce a server-side plot with `matplotlib`.
62+
The app provides an API to produce plots with `matplotlib`.
8763
The API can return a JSON response with the base64-encoded image, or
8864
the bytes content to be saved as a file.
8965

@@ -146,4 +122,4 @@ The plot will be saved in `./plot.png`
146122
## Donation
147123
If you liked this project or if I saved you some time, feel free to buy me a beer. Cheers!
148124

149-
[![paypal](https://www.paypalobjects.com/en_US/IT/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PMW6C23XTQDWG)
125+
[![paypal](https://www.paypalobjects.com/en_US/IT/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PMW6C23XTQDWG)

README_IT.md

Lines changed: 0 additions & 148 deletions
This file was deleted.

app/api/__init__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)