KG-Enricher is a web service built to enrich knowledge graphs generated by the News Hunter platform, part of the News Angler project.
NOTE: replace text in <braces>
Navigate to the root of the repository and run:
docker build -t <image name> .
docker run -p 80:80 <environment variables> <image name>
The image expects the following environment variables:
Variable | Explanation | Example Value |
---|---|---|
yago_endpoint | Yago4 SPARQL endpoint | https://yago-knowledge.org/sparql/query |
yago_endpoint_max_connections | Maximum number of concurrent requests to the Yago4 endpoint | 10 |
wd_endpoint | Wikidata SPARQL endpoint | https://query.wikidata.org/sparql |
wd_endpoint_max_connections | Maximum number of concurrent requests to the Wikidata endpoint | 5 |
The environment variables can be supplied as arguments or with a file.
docker run -p 80:80 --env yago_endpoint=https://yago-knowledge.org/sparql/query --env yago_endpoint_max_connections=10 --env wd_endpoint=https://query.wikidata.org/sparql --env wd_endpoint_max_connections=5 <image name>
docker run -p 80:80 --env-file .\example.env <image name>
Navigate to the root of the repository before proceeding.
Create the environment:
py -m venv env
Then activate it:
.\env\Scripts\activate
pip install -r dev-requirements.txt
You can set the environment variables in your shell or use a file like in the Docker example.
First navigate to the app directory:
cd app
Then run uvicorn to start the app:
uvicorn main:app --reload --port 8000
You can also provide an env file for the environment variables:
uvicorn main:app --reload --port 8000 --env-file <path to env file>
It is also possible to debug the app in VS Code. This makes it possible to set breakpoints, etc. But keep in mind that it has a major performance impact.
All you need to do is to create a launch configuration for the project and add the following configuration to it:
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"main:app",
"--reload",
"--port",
"8000"
],
"env": {
"yago_endpoint": "https://yago-knowledge.org/sparql/query",
"yago_endpoint_max_connections": "5",
"wd_endpoint": "https://query.wikidata.org/sparql",
"wd_endpoint_max_connections": "5",
},
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/app"
}
You can of course customize the properties in "env" to your liking.