Skip to content

Commit 2812d60

Browse files
committed
Improve documentation
This adds significantly to the `README.md`. Furthermore, we adapt the `fastapi.API()` class to include more documentation which gets displayed in the automatically generated OpenAPI specification of the interface. Fixes #13
1 parent a2155cc commit 2812d60

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

README.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,56 @@
11
# Python Semantic Matching Service
22

3-
This is a proof-of-concept implementation of a semantic matching service
4-
using Python.
3+
This is a proof-of-concept implementation of a semantic matching service using Python.
4+
The idea behind this service is to create a uniform interface for exchanging semantic matches, that are stored
5+
decentralized across multiple semantic matching services.
56

6-
## Docker
7+
> [!warning]
8+
> This project is **not** about finding semantic matches or semantic similarities, it rather requires these as input.
79
10+
## Structure
11+
The project is structured as follows:
12+
- `algorithm.py` implements the decentralized match aggregation algorithm
13+
- `service.py` offers the service implementation using the [FastAPI](https://fastapi.tiangolo.com/) framework.
14+
Note that you can find a detailed interface description (OpenAPI) by [running](#how-to-use) the server locally and
15+
navigating to `<endpoint>/docs`.
16+
17+
## How to Use
18+
There are two main options to run:
19+
20+
### Run `service.py`
21+
You need a working Python installation (3.11 or higher).
22+
- Clone this repository
23+
- Create a new virtual environment: `python3 -m venv venv` (Note that the service is only tested on Linux systems)
24+
- Activate the virtual environment: `source venv/bin/activate`
25+
- Install the package: `pip install .`
26+
- Copy the `config.ini.default` to `config.ini` and adapt the fields as necessary
27+
- Run the service: `python3 semantic_matcher/service.py`
28+
29+
### Run via Docker
30+
To run via docker, you obviously need a working docker installation.
31+
- Clone the repository
32+
- Copy the `config.ini.default` to `config.ini` and adapt the fields as necessary
33+
- Choose one of the two options below:
34+
35+
**Option 1:** Build and run manually
36+
37+
In the project root directory:
838
```commandline
939
docker build -t semantic_matching_service .
1040
```
1141
```commandline
1242
docker run -d -p 8000:8000 semantic_matching_service
1343
```
44+
45+
> [!note]
46+
> You may have to change the port in the run command if you changed it in your `config.ini`.
47+
48+
**Option 2:** Use the docker compose file
49+
50+
In the project root directory:
51+
```commandline
52+
docker compose up
53+
```
54+
55+
> [!note]
56+
> If you changed your `config.ini`, you might need to adapt the respective fields in the `compose.yaml`.

semantic_matcher/service.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,16 @@ def _get_matcher_from_semantic_id(semantic_id: str) -> Optional[str]:
203203
endpoint=config["SERVICE"]["endpoint"],
204204
graph=match_graph,
205205
)
206-
APP = FastAPI()
206+
with open("../README.md", "r") as file:
207+
description = file.read()
208+
APP = FastAPI(
209+
title="Semantic Matching Service",
210+
description=description,
211+
contact={
212+
"name": "Sebastian Heppner",
213+
"url": "https://github.com/s-heppner",
214+
},
215+
)
207216
APP.include_router(
208217
SEMANTIC_MATCHING_SERVICE.router
209218
)

0 commit comments

Comments
 (0)