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
Allow deployment of multiple sets of services (#289)
Update the compose file to allow easy deployment of multiple sets of
services:
- ports are not bound by default, but through `compose.ports.yaml`
- containers do not have a fixed name
There are three important [test markers](https://docs.pytest.org/en/7.1.x/example/markers.html) to be aware of:
63
68
@@ -69,15 +74,15 @@ In many cases during development it's sufficient to either run with `not php_api
69
74
The `not slow` is only needed if a slow test would be included in your test selection. In many cases, you might prefer to only run the specific tests (or test modules) that you are working on and excluding it through markers may be unnecessary.
70
75
Examples:
71
76
72
-
-`docker exec openml-python-rest-api python -m pytest tests -m "not php_api and not slow"`, here the test selection is made primarily through markers. This command takes a few seconds.
73
-
-`docker exec openml-python-rest-api python -m pytest tests/routers/openml/dataset_tag_test.py`, here the test selection is made through specifying the file with tests. Since this test file naturally includes neither migration tests (in `tests/routers/openml/migration`) nor the slow test (at `tests/routers/openml/datasets_list_datasets_test.py`), excluding tests through markers is unnecessary. This command takes a few seconds.
77
+
-`docker compose exec python-api python -m pytest tests -m "not php_api and not slow"`, here the test selection is made primarily through markers. This command takes a few seconds.
78
+
-`docker compose exec python-api python -m pytest tests/routers/openml/dataset_tag_test.py`, here the test selection is made through specifying the file with tests. Since this test file naturally includes neither migration tests (in `tests/routers/openml/migration`) nor the slow test (at `tests/routers/openml/datasets_list_datasets_test.py`), excluding tests through markers is unnecessary. This command takes a few seconds.
74
79
75
80
76
81
You don't always need every container, often just having a database and the Python-based
77
82
REST API may be enough. In that case, only specify those services:
78
83
79
84
```bash
80
-
docker compose --profile python up -d
85
+
docker compose up python-api -d
81
86
```
82
87
83
88
Refer to the `docker compose` documentation for more uses.
@@ -87,18 +92,18 @@ Refer to the `docker compose` documentation for more uses.
87
92
88
93
### Connecting to containers
89
94
90
-
To connect to a container, run:
95
+
To connect to a container of a service, run:
91
96
92
97
```bash
93
-
docker exec-it CONTAINER_NAME /bin/bash
98
+
docker compose execSERVICE_NAME /bin/bash
94
99
```
95
100
96
-
where `CONTAINER_NAME` is the name of the container. If you are unsure of your container
97
-
name, then `docker container ls` may help you find it. Assuming the default container
101
+
where `SERVICE_NAME` is the name of the service. If you are unsure of the service
102
+
name, then `docker compose ps` may help you find it. Assuming the default service
98
103
names are used, you may connect to the Python-based REST API container using:
99
104
100
105
```bash
101
-
docker exec-it openml-python-rest-api /bin/bash
106
+
docker compose exec python-api /bin/bash
102
107
```
103
108
104
109
This is useful, for example, to run unit tests in the container:
Copy file name to clipboardExpand all lines: docs/installation.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,16 @@ See also ["Contributing"](contributing/contributing.md).
4
4
5
5
The primary way to run this service is through a Docker container.
6
6
The REST API needs to be able to connect to a MySQL database with the OpenML "openml" and "openml_expdb" databases.
7
-
The `docker-compose.yaml` file of this project defines these together out of the box.
7
+
The `compose.yaml` file of this project defines these together out of the box.
8
8
This is useful for development purposes, but the database does not persist between restarts in the current configuration.
9
9
By default, the current code is also mounted into the Python REST API container (again, for development purposes).
10
10
11
-
For development, it should suffice to run the services from a fresh clone by running `docker compose --profile "python" up -d`.
12
-
The REST API will be exposed on port 8001 on the host machine. To visit the Swagger Docs, visit http://localhost:8001/docs.
11
+
For development, it should suffice to run the services from a fresh clone by running `docker compose up python-api -d`.
12
+
If you want to make sure to bind the exposed container ports to the host machine then you will need to use the `compose.ports.yaml` file too (`docker compose -f compose.yaml -f compose.ports.yaml up python-api -d`).
13
+
The REST API will then be exposed on port 8001 on the host machine. To visit the Swagger Docs, visit http://localhost:8001/docs.
13
14
14
-
Once the containers are started, you can run tests with `docker exec -it openml-python-rest-api python -m pytest -m "not php_api" tests`.
15
-
For migration testing, which compares output of the Python-based REST API with the old PHP-based one, also start the PHP server (`docker compose --profile "php" --profile "python" up -d`) and include tests with the `php_api` marker/fixture: `docker exec -it openml-python-rest-api python -m pytest tests`.
15
+
Once the containers are started, you can run tests with `docker compose exec python-api python -m pytest -m "not php_api" tests`.
16
+
For migration testing, which compares output of the Python-based REST API with the old PHP-based one, also start the PHP server (`docker compose --profile "apis" up -d`) and include tests with the `php_api` marker/fixture: `docker compose exec python-api python -m pytest tests`.
16
17
17
18
!!! note
18
19
@@ -21,4 +22,4 @@ For migration testing, which compares output of the Python-based REST API with t
21
22
When we start testing more upload functionality, for which the PHP API needs built indices, we'll work on an ES image with prebuilt indices.
22
23
23
24
Information for a production deployment will follow, in a nutshell you need to configure the REST API to connect to a persistent database,
24
-
which can be the one defined in `docker-compose.yaml` if has an appropriately mounted volume.
25
+
which can be the one defined in `compose.yaml` if it has an appropriately mounted volume.
0 commit comments