You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please continue reading for more information on each one of those services. If running into issues during the setup please check the [troubleshooting](/docs/troubleshooting.md) document. Also feel free to reach out to us.
14
+
For development setup please continue reading.
16
15
17
16
18
-
## Database
19
-
20
-
A database for development purposes is provided as Dockerfile. This database contains custom regions, regions for running tests and datasets (E.g. SHDI) for those regions. To build and run an already configured image run:
21
-
22
-
```bash
23
-
docker compose up --detach database
24
-
```
25
-
26
-
During building of the database Docker image data for development purposes is downloaded. When the database container is running for the first time it takes a few seconds until the database is initialized and ready to accept connections.
27
-
Check the progress with `docker logs database`.
28
-
29
-
To reinitialize or update the database make sure to delete the volume and rebuild the image. This will delete all data in the database:
30
-
31
-
```bash
32
-
# Make sure that your git is up2date, e.g. git pull
33
-
docker compose down --remove-orphans --volumes
34
-
docker compose up --detach --force-recreate --build database
35
-
```
36
-
37
-
To avoid using the cache of Docker run:
38
-
39
-
```bash
40
-
docker compose build --no-cache database
41
-
docker compose up --detach database
42
-
```
43
-
44
-
> If for development purposes additional datasets are required please have a look at the scripts found in the `database/init_db.production` directory.
45
-
46
-
47
-
### Database for running tests
48
-
49
-
A minimal database setup for running tests is provided. If the build argument `OQT_TEST_DB` is set to `True` a database is initialized with data only for the regions used by the tests. No (additional) data is downloaded as is the case with the database setup for development.
50
-
51
-
52
-
## Raster Datasets
53
-
54
-
Please refer to [/docs/raster_datasets.md](/docs/raster_datasets.md).
55
-
56
-
57
-
## OQT Python package
58
-
59
-
60
-
### Requirements
17
+
## Requirements
61
18
62
19
- Python: ≥ 3.10
63
20
- Poetry: ≥ 1.5
64
21
- R: ≥ 4.0
65
22
66
-
This project uses [Poetry](https://python-poetry.org/docs/) for packaging and dependencies management. Please make sure it is installed on your system using `pip`.
23
+
This project uses [Poetry](https://python-poetry.org/docs/) for packaging and dependencies management. Please make sure it is installed on your system.
67
24
25
+
For development a database and raster datasets on disk might not be needed. In case the database is needed start the database service defined in the docker compose file. If raster datasets are needed please refer to [/docs/raster_datasets.md](/docs/raster_datasets.md) for setting those up.
68
26
69
-
### Installation
27
+
28
+
## Installation
70
29
71
30
```bash
72
31
poetry install
73
32
poetry shell # Spawns a shell within the virtual environment.
74
33
pre-commit install # Install pre-commit hooks.
75
34
# Hack away
35
+
pytest # Run all tests
76
36
```
77
37
78
38
79
-
###Configuration
39
+
## Configuration
80
40
81
41
For all possible configuration parameter please refer to the [configuration documentation](/docs/configuration.md).
82
42
83
-
For local development no additional configuration is required. Per default OQT will connect to the database defined in `docker-compose.yml`.
84
-
85
-
86
-
### Usage
87
-
43
+
For local development no custom configuration is required.
88
44
89
-
#### API
90
45
91
-
92
-
##### Start the API using Docker:
46
+
## Usage
93
47
94
48
```bash
95
-
docker compose up --detach workers
49
+
python scripts/start_api.py
96
50
```
97
51
98
-
99
-
##### Start the API using a Python script:
100
-
101
-
```bash
102
-
cd scripts
103
-
python start_api.py
104
-
```
52
+
Go to [http://127.0.0.1:8080/docs](http://127.0.0.1:8080/docs) and check out the endpoints.
105
53
106
54
Default host is 127.0.0.1 and port is 8080. To change this, provide the corresponding parameter:
107
55
108
56
```bash
109
-
python start_api.py --help
57
+
$ cd scripts
58
+
$ python start_api.py --help
110
59
Usage: start_api.py [OPTIONS]
111
60
112
61
Options:
@@ -116,55 +65,7 @@ Options:
116
65
```
117
66
118
67
119
-
##### Endpoints
120
-
121
-
Go to [http://127.0.0.1:8080/docs](http://127.0.0.1:8080/docs) and check out the endpoints.
122
-
123
-
Alternative query the API from a terminal using CURL:
All relevant components should be tested. Please write tests for newly integrated
170
71
functionality.
@@ -177,9 +78,7 @@ To run all tests just execute `pytest`:
177
78
pytest
178
79
```
179
80
180
-
#### Writing tests
181
-
182
-
##### VCR (videocassette recorder) for tests
81
+
### VCR for Tests
183
82
184
83
All tests that are calling function, which are dependent on external resources (e.g. ohsome API) have to use the [VCR.py](https://vcrpy.readthedocs.io) module: "VCR.py records all HTTP interactions that take place […]."
185
84
This ensures that the positive test result is not dependent on the external resource. The cassettes are stored in the test directory within [fixtures/vcr_cassettes](/tests/integrationtests/fixtures/vcr_cassettes). These cassettes are supposed to be integrated (committed and pushed) to the repository.
@@ -199,26 +98,26 @@ def test_something(self):
199
98
200
99
Good examples can be found in [test_oqt.py](/tests/integrationtests/test_oqt.py).
201
100
202
-
#####Asynchronous functions
101
+
### Asynchronous functions
203
102
204
103
When writing tests for functions which are asynchronous (using the `async/await` pattern) such as the `preprocess` functions of indicator classes, those functions should be called as follows: `asyncio.run(indicator.preprocess())`.
205
104
206
105
207
-
###Logging
106
+
## Logging
208
107
209
108
Logging is enabled by default.
210
109
211
110
`ohsome_quality_analyst` uses the [logging module](https://docs.python.org/3/library/logging.html).
212
111
213
-
####Configuration
112
+
### Configuration
214
113
215
114
The logging module is configured in `config.py`. Both entry-points to
216
115
`ohsome_quality_analyst`, the `api.py`, will call the configuration
217
116
function defined in `definitions.py`. The default log level is `INFO`. This can be
218
117
overwritten by setting the environment variable `OQT_LOG_LEVEL` (See also the
0 commit comments