Skip to content

Commit 9e757b3

Browse files
committed
initial changes
1 parent 18abeaa commit 9e757b3

13 files changed

+179
-266
lines changed
136 KB
Loading

docs/source/configuration.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@ In following chapters configuration values and keys are discussed for each part
1313
All configuration values for MapSwipe Workers are stored in environment variables.
1414

1515
Required environment variables are:
16+
### Firebase
1617
- FIREBASE_API_KEY
1718
- FIREBASE_DB
19+
- FIREBASE_TOKEN
20+
- GOOGLE_APPLICATION_CREDENTIALS
21+
22+
### Postgres DB
1823
- POSTGRES_DB
1924
- POSTGRES_HOST
2025
- POSTGRES_PASSWORD
2126
- POSTGRES_PORT
2227
- POSTGRES_USER
2328

24-
Optional environment variables are:
29+
### OSMCha
30+
31+
- OSMCHA_API_KEY
32+
33+
### Optional environment variables:
2534
- SLACK_CHANNEL
2635
- SLACK_TOKEN
2736
- SENTRY_DSN
@@ -34,19 +43,16 @@ For satellite imagery access to at least one provider is needed. Define the API
3443
- IMAGE_ESRI_API_KEY
3544
- IMAGE_ESRI_BETA_API_KEY
3645

37-
In addition to get access to Firebase a Service Account Key is required.
38-
The path the Service Account Key is defined in:
39-
- GOOGLE_APPLICATION_CREDENTIALS
40-
4146
> Notes: When deploying using `docker` or `docker-compose` `POSTGRES_HOST` should have the value `postgres` and the Service Account Key (`serviceAccountKey.json`) should be copied to `mapswipe_workers/serviceAccountKey.json` so that during the build of the image the file can by copied by Docker.
4247
43-
4448
### Elaboration
4549

4650
**Firebase**: MapSwipe Workers use the Firebase Python SDK and the Firebase REST API. Both require the database name (`FIREBASE_DB`) and the API-Key from the Firebase instance. The Firebase Python SDK does also need a Service Account Key. The path to this file is set in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
4751

4852
**Postgres**: MapSwipe Workers writes data to a Postgres database and generate files for the API based data in Postgres.
4953

54+
**OSMCha**: MapSwipe Workers enriches some Projects with data from OSM changelogs which are requested from OSMCha. Create an account, you will find you api key in your profile e.g. `Token 589adf125234a`
55+
5056
**Sentry (optional)**: MapSwipe workers use sentry to capture exceptions. You can find your project’s DSN in the “Client Keys” section of your “Project Settings” in Sentry. Check [Sentry's documentation](https://docs.sentry.io/error-reporting/configuration/?platform=python) for more information.
5157

5258
**Slack (optional)**: The MapSwipe workers send messages to slack when a project has been created successfully, the project creation failed or an exception gets raised. refer to [Python slackclient's documentation](https://github.com/slackapi/python-slackclient) how to get a Slack Token.
@@ -80,13 +86,26 @@ The Service Account Key (`serviceAccountKey.json`) should be saved to `postgres/
8086

8187
## Manager Dashboard
8288

89+
Please refer to the official [documentation](https://firebase.google.com/docs/web/learn-more#config-object) if you set up your own firebase.
90+
Otherwise you can request guidance on the settings from the mapswipe team. The structure of your app.js should look like below.
91+
8392
`manager_dashboard/manager_dashboard/js/app.js`
8493

8594
```
86-
TODO
95+
// Your web app's Firebase configuration
96+
var firebaseConfig = {
97+
apiKey: "",
98+
authDomain: "",
99+
databaseURL: "",
100+
projectId: "",
101+
storageBucket: "",
102+
messagingSenderId: "",
103+
appId: ""
104+
};
105+
// Initialize Firebase
106+
firebase.initializeApp(firebaseConfig);
87107
```
88108

89-
90109
## NGINX
91110

92111
`nginx/nginx.conf`:

docs/source/contributing.md

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

docs/source/data.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Attributes:
3131

3232

3333
## Aggregated Results
34-
This gives you the unfiltered MapSwipe results. This is most suited if you want to apply some custom data processing with the MapSwipe data, e.g. select only specific tasks for machine learning. If you want to use MapSwipe data in the Tasking Manager you might look for the data explained below.
34+
This gives you the unfiltered MapSwipe results. This is most suited if you want to apply some custom data processing with the MapSwipe data, e.g. select only specific tasks for machine learning. If you want to use MapSwipe data in the Tasking Manager you might look for the data described below.
3535

3636
Files:
3737
- `aggregated_results_{project_id}.csv`, e.g. [agg\_results\_-M56eeMCZ5VeOHjJN4Bx.csv](https://apps.mapswipe.org/api/agg_results/agg_results_-M56eeMCZ5VeOHjJN4Bx.csv)
@@ -51,11 +51,11 @@ Files:
5151
| 2_share | float | 2_count divived by total_count. This gives you the share of all users who marked as 2. |
5252
| 3_share | float | 3_count divived by total_count. This gives you the share of all users who marked as 3. |
5353
| agreement | float | This is defined as [Scott's Pi](https://en.wikipedia.org/wiki/Scott%27s_Pi) and gives you an understanding of inter-rater reliability. The value is 1.0 if all users agree, e.g. all users classify as "building". If users disagree this value will be lower. |
54-
| geom | string | The geometry of this task as WKT geometry. |
54+
| geom | string | The geometry of this task as WKT geometry. |
5555

5656

57-
## HOT Tasking Manager Geometries
58-
This gives you filtered MapSwipe data ready to be imported to the HOT Tasking Manager. Currently, the geometries in this dataset consist of maximum 15 MapSwipe Tasks, where at least 35% of all users indicated the presence of a building by classifying as "yes" or "maybe".
57+
## HOT Tasking Manager Geometries
58+
This gives you filtered MapSwipe data ready to be imported to the HOT Tasking Manager. Currently, the geometries in this dataset consist of maximum 15 MapSwipe Tasks, where at least 35% of all users indicated the presence of a building by classifying as "yes" or "maybe".
5959

6060
Files:
6161
- `hot_tm_{project_id}.geojson`, e.g. [hot\_tm\_-M56eeMCZ5VeOHjJN4Bx.geojson](https://apps.mapswipe.org/api/hot_tm/hot_tm_-M56eeMCZ5VeOHjJN4Bx.geojson)

docs/source/deployment_overview.md

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

docs/source/dev_setup.md

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Development Setup
22

3-
In this document some tips and workflows for development are loosely collected. Those are independent of the production setup using Docker-Compose. A working Firebase Project (Including Firebase Functions and Database Rules) is presupposed. Get in touch with the MapSwipe team (e.g. in Slack) to get access to an existing Firebase Instance for development purposes.
3+
In this document some tips and workflows for development are loosely collected.
4+
Those are independent of the production setup using Docker-Compose.
5+
A working Firebase Project (Including Firebase Functions and Database Rules) is presupposed.
6+
Get in touch with the MapSwipe team (e.g. in Slack) to get access to an existing Firebase Instance for development purposes.
47

58
Check list:
69
1. Clone repo from GitHub.
@@ -15,7 +18,8 @@ Check list:
1518

1619
### Requirements
1720

18-
MapSwipe Workers requires GDAL/OGR (`gdal-bin`) and GDAL for Python (`libgdal-dev`, `python-gdal`) to be installed. Furthermore, we rely on Docker to set up Postgres.
21+
MapSwipe Workers requires GDAL/OGR (`gdal-bin`) and GDAL for Python (`libgdal-dev`, `python-gdal`) to be installed.
22+
Furthermore, we rely on Docker to set up Postgres.
1923

2024

2125
### Clone from GitHub
@@ -48,16 +52,19 @@ mkdir --parents ~/.local/share/mapswipe_workers
4852

4953
### Service Account Key
5054

51-
The MapSwipe Workers requires a Service Account Key (`serviceAccountKey.json`) to access Firebase database. Request yours from the MapSwipe working group.
55+
The MapSwipe Workers requires a Service Account Key (`serviceAccountKey.json`) to access Firebase database.
56+
Request yours from the MapSwipe working group.
5257

53-
The path the Service Account Key is defined in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
58+
The path to the Service Account Key is defined in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
5459

55-
You could also set up your own Firebase instance. However, this is not recommended. If you still want to do it, get your Service Account Key from Firebase from [Google Cloud Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts).
60+
You could also set up your own Firebase instance. However, this is not recommended.
61+
If you still want to do it, get your Service Account Key from Firebase from [Google Cloud Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts).
5662

5763

5864
### Postgres
5965

60-
Setup a local Postgres instance for MapSwipe Workers using the Dockerfile provided for development purposes (`postgres/Dockerfile-dev`). The Dockerfile for production (`postgres/Dockerfile`) does need additional setup for build-in backup to Google Cloud Storage, which is not needed for local development. That is why a simplified Dockerfile for development is provided.
66+
Setup a local Postgres instance for MapSwipe Workers using the Dockerfile provided for development purposes (`postgres/Dockerfile-dev`).
67+
The Dockerfile for production (`postgres/Dockerfile`) does need additional setup for build-in backup to Google Cloud Storage, which is not needed for local development. That is why a simplified Dockerfile for development is provided.
6168
Make sure that the specified port is not in use already. If so, adjust the port (also in the `.env` file).
6269

6370
```bash
@@ -90,7 +97,8 @@ mapswipe_workers --help
9097

9198
## Logging
9299

93-
Mapswipe workers logs are generated using the Python logging module of the standard library (See [Official docs](https://docs.python.org/3/library/logging.html) or this [Tutorial](https://realpython.com/python-logging/#the-logging-module). To use the logger object import the it from the `definitions` module:
100+
Mapswipe workers logs are generated using the Python logging module of the standard library (See [Official docs](https://docs.python.org/3/library/logging.html) or this [Tutorial](https://realpython.com/python-logging/#the-logging-module).
101+
To use the logger object import the it from the `definitions` module:
94102

95103
```python
96104
from mapswipe_workers.definitions import logger
@@ -104,9 +112,11 @@ except Exception:
104112
logger.exception('Additional information.')
105113
```
106114

107-
Default logging level is Info. To change the logging level edit the logging configuration which is found in the module `definitions.py`. Logs are written to STDOUT and `~/.local/share/mapswipe_workers/mapswipe_workers.log`.
115+
Default logging level is Info. To change the logging level edit the logging configuration which is found in the module `definitions.py`.
116+
Logs are written to STDOUT and `~/.local/share/mapswipe_workers/mapswipe_workers.log`.
108117

109-
Per default logging of third-party packages is disabled. To change this edit the definition module (`mapswipe_workers/defintions.py`). Set the `disable_existing_loggers` parameter of the `logging.config.fileConfig()` function to `False`.
118+
Per default logging of third-party packages is disabled. To change this edit the definition module (`mapswipe_workers/defintions.py`).
119+
Set the `disable_existing_loggers` parameter of the `logging.config.fileConfig()` function to `False`.
110120

111121

112122
## Firebase Functions
@@ -128,38 +138,12 @@ Firebase functions are used to increment/decrement or calculate various attribut
128138

129139
Those functions will be directly or indirectly triggered by incoming results from the MapSwipe App.
130140

131-
By using Firebase functions those attributes can be calculated in real-time and be accessed by users immediately. The use of those functions also reduces the data-transfer between the Firebase Realtime Database and MapSwipe Workers.
132-
133-
On how to setup development environment and how to deploy functions to the Firebase instance please refer to the official [Guide on Cloud Function for Firebase](https://firebase.google.com/docs/functions/get-started).
134-
For more information refer to the official [Reference on Cloud Function for Firebase](https://firebase.google.com/docs/reference/functions/). For example function take a look at this [GitHub repository](https://github.com/firebase/functions-samples).
135-
136-
137-
## Travis Setup
138-
139-
A Travis instance is used to build MapSwipe Workers and run tests.
140-
There exists a Firebase instance only for Travis.
141-
For the configuration of Travis following environment variables are used:
142-
143-
- FIREBASE_API_KEY
144-
- FIREBASE_DB
145-
- FIREBASE_TOKEN
146-
- POSTGRES_DB
147-
- POSTGRES_HOST
148-
- POSTGRES_PASSWORD
149-
- POSTGRES_PASSWORD
150-
- POSTGRES_USER
151-
- WALG_GS_PREFIX: empty
152-
- GOOGLE_APPLICATION_CREDENTIALS: mapswipe_workers/serviceAccountKey.json
153-
154-
Those variables can be definied directly in the repository settings of Travis. For more inofmration refer to: https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings
155-
156-
Additionaly a Service Account Key in JSON format is encrypted and added to the GitHub repository using the travis CLI. Once Travis runs it will decrypt the Service Account Key. Read more on that process in the Travis docs: https://docs.travis-ci.com/user/encrypting-files/
157-
158-
Once a Travis build succeeds Travis executes an Ansible Playbook to deploy MapSwipe Workers to an already installed and configured server.
159-
For this to work an SSH-Key (with access rights to the server) is also encrypted and added to the GitHub repository. Travis will decrypt the key and Ansible will use it to execute commands defined in the Playbook on the server.
160-
161-
All files encrypted for Travis (Service Account Key, SSH-Key) are stored in the `travis` directory.
141+
By using Firebase functions those attributes can be calculated in real-time and be accessed by users immediately.
142+
The use of those functions also reduces the data-transfer between the Firebase Realtime Database and MapSwipe Workers.
162143

144+
On how to setup the development environment and how to deploy functions to the Firebase instance please refer to the official [Guide on Cloud Function for Firebase](https://firebase.google.com/docs/functions/get-started).
145+
For more information refer to the official [Reference on Cloud Function for Firebase](https://firebase.google.com/docs/reference/functions/).
146+
For example function take a look at this [GitHub repository](https://github.com/firebase/functions-samples).
163147

164148
## Database Backup
165149

docs/source/for_mapswipe_managers.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ For BuildArea and ChangeDetection projects:
2222
For Footprint projects:
2323
* The GeoJSON file should contain only simple Polygons. We currently don't support complex Multipolygon geometries (e.g. [polygon with holes](https://developers.google.com/maps/documentation/javascript/examples/polygon-hole))
2424

25-
Once you submit, the task should appear relatively quickly in the manager dashboard. You will receive a message in Slack. But it's still not active and not visible to the MapSwipe app users. You need to set the project status to `active` through the manager dashboard. Just click on the respective button. If the new project does not appear in the app after about 1 hour, check Slack for an error message, and see Troubleshooting below.
25+
Once you submit, the task should appear relatively quickly in the manager dashboard. You will receive a message in Slack.
26+
But it's still not active and not visible to the MapSwipe app users.
27+
You need to set the project status to `active` through the manager dashboard. Just click on the respective button.
28+
If the new project does not appear in the app after about 1 hour, check Slack for an error message, and see Troubleshooting below.
2629

2730
![Project Management](_static/img/manager_dashboard_manage_screenshot.png)
2831

docs/source/index.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,40 @@ Welcome to MapSwipe Back-End's documentation!
1313

1414
readme_link
1515
overview
16-
contributing
16+
data
17+
dev_setup
18+
testing
19+
20+
21+
.. toctree::
22+
:maxdepth: 2
23+
:caption: Project Types:
24+
25+
project_type
26+
project_type-buildArea
27+
project_type-changeDetection
28+
project_type-footprint
1729

1830
.. toctree::
1931
:maxdepth: 2
20-
:caption: Using:
32+
:caption: Usage:
2133

2234
for_mapswipe_managers
2335
use_cases
2436
tile_size
25-
data
2637

2738

2839
.. toctree::
2940
:maxdepth: 2
3041
:caption: Deployment:
3142

32-
deployment_overview
3343
configuration
3444
installation
3545
cli
3646
debugging
3747
backup
3848

3949

40-
.. toctree::
41-
:maxdepth: 2
42-
:caption: Development:
43-
44-
dev_setup
45-
testing_and_travis
46-
47-
4850
Indices and tables
4951
==================
5052

0 commit comments

Comments
 (0)