Skip to content

Commit 128f03b

Browse files
authored
Merge pull request #536 from mapswipe/dev
Dev
2 parents f904877 + be95cfe commit 128f03b

36 files changed

+725
-679
lines changed

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
working-directory: ./mapswipe_workers
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install flake8 black==19.10b0 isort
23+
pip install flake8 black==22.3.0 isort
2424
- name: Code style
2525
working-directory: ./mapswipe_workers
2626
run: |
127 KB
Loading
136 KB
Loading

docs/source/cli.md

Lines changed: 4 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Command Line Interface
22

3-
THIS DOCUMENT IS OUTDATED: Please use the `--help` flag of the CLI.
3+
The Mapswipe Backend provides a Command Line Interface(CLI) with which the users can interact with the program.
4+
They can be used for example to create projects, which were uploaded to the [manager-dashboard](for_mapswipe_managers.html),
5+
or to export statistics on the finished projects. To get a comprehensible lists of the available commands use the ```--help``` flag.
46

5-
---
6-
7-
This document describes how to use the command line interface of MapSwipe Worker.
7+
```mapswipe_workers --help``` would get you all possible commands, while e.g. ```mapswipe_workers archive --help``` would get you additional information on how to use that command.
88

99
In our current deployment setup the commands of the MapSwipe Workers CLI are hard-coded in the Docker-Compose File.
1010

@@ -13,148 +13,3 @@ You can run these commands also using docker-compose:
1313
```
1414
docker-compose run mapswipe_workers mapswipe_workers --help
1515
```
16-
17-
18-
```
19-
Usage: mapswipe_workers [OPTIONS] COMMAND [ARGS]...
20-
21-
Options:
22-
-v, --verbose
23-
--version Show the version and exit.
24-
--help Show this message and exit.
25-
26-
Commands:
27-
create-projects
28-
create-tutorial
29-
firebase-to-postgres
30-
generate-stats
31-
run
32-
user-management
33-
```
34-
35-
36-
## Create projects from submitted project drafts
37-
38-
```
39-
Usage: mapswipe_workers create-projects [OPTIONS]
40-
41-
Options:
42-
-s, --schedule [m|h|d] Will create projects every 10 minutes (m), every
43-
hour (h) or every day (d).
44-
--help Show this message and exit.
45-
```
46-
47-
48-
## Transfer data from Firebase to Postgres
49-
50-
```
51-
Usage: mapswipe_workers firebase-to-postgres [OPTIONS]
52-
53-
Options:
54-
-s, --schedule [m|h|d] Will update and transfer relevant data (i.a. users
55-
and results) from Firebase into Postgres every 10
56-
minutes (m), every hour (h) or every day (d).
57-
--help Show this message and exit.
58-
```
59-
60-
61-
## Generate Statistics
62-
63-
```
64-
Usage: mapswipe_workers generate-stats [OPTIONS]
65-
66-
Options:
67-
-s, --schedule [m|h|d] Generate stats every 10 minutes (m), every hour (h)
68-
or every day (d).
69-
--project_id_list TEXT provide project id strings as a list stats will be
70-
generated only for these projects.
71-
Use it like '["project_a", "project_b"]'
72-
--help Show this message and exit.
73-
```
74-
75-
## Generate Statistics for all projects
76-
77-
Ideally you run this using a separate docker container. e.g. like this:
78-
79-
```
80-
docker-compose run mapswipe_workers mapswipe_workers generate-stats-all-projects
81-
```
82-
83-
```
84-
Usage: mapswipe_workers generate-stats-all-projects [OPTIONS]
85-
86-
Options:
87-
-s, --schedule [m|h|d] Generate stats every 10 minutes (m), every hour (h)
88-
or every day (d).
89-
--help Show this message and exit.
90-
```
91-
92-
## User Management
93-
94-
```
95-
Usage: mapswipe_workers user-management [OPTIONS]
96-
97-
Options:
98-
--email TEXT The email of the MapSwipe user. [required]
99-
--manager BOOLEAN Set option to grant or remove project manager
100-
credentials. Use true to grant credentials. Use false to
101-
remove credentials.
102-
--help Show this message and exit.
103-
```
104-
105-
## Archive Projects
106-
107-
```
108-
Usage: mapswipe_workers archive [OPTIONS]
109-
110-
Archive projects in Postgres. Delete groups, tasks and results from
111-
Firebase.
112-
113-
Options:
114-
-i, --project-id TEXT Archive project with giving project id
115-
--project-ids TEXT Archive multiple projects. Provide project id strings
116-
as a list: '["project_a", "project_b"]'
117-
118-
--help Show this message and exit.
119-
120-
```
121-
122-
You can get the project ids for the projects to be archive either from the manager dashboard or query directly in postgres. For example:
123-
124-
```
125-
SELECT project_id
126-
FROM projects
127-
WHERE status = 'finished' AND created < '2020-09-01'
128-
```
129-
130-
## Delete Projects
131-
132-
```
133-
Usage: mapswipe_workers delete [OPTIONS]
134-
135-
Delete tasks, groups, project and results.
136-
137-
Options:
138-
-i, --project-id TEXT Delete project with giving project id
139-
--project-ids TEXT Delete multiple projects. Provide project id strings
140-
as a list: '["project_a", "project_b"]'
141-
142-
--help Show this message and exit.
143-
```
144-
145-
146-
## Create Tutorial from json file (e.g. provided in sample data)
147-
148-
```
149-
Usage: mapswipe_workers create-tutorial [OPTIONS]
150-
151-
Options:
152-
--input_file TEXT The json file with your tutorial information. [required]
153-
--help Show this message and exit.
154-
155-
```
156-
157-
## Run a script which requires mapswipe_workers library
158-
```
159-
docker-compose run mapswipe_workers python3 python_scripts/add_project_geometries_to_api.py
160-
```

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.

0 commit comments

Comments
 (0)