The Metadata Service provides API for retrieving JSON metadata of GUIDs.
The server is built with FastAPI and packaged with Poetry.
Install required software:
- PostgreSQL 9.6 or above
- Python 3.7 or above
- Poetry
Then use poetry install
to install the dependencies. Before that,
a virtualenv is recommended.
If you don't manage your own, Poetry will create one for you
during poetry install
, and you must activate it by:
poetry shell
Create a file .env
in the root directory of the checkout:
(uncomment to override the default)
# DB_HOST = "..." # default: localhost
# DB_PORT = ... # default: 5432
# DB_USER = "..." # default: current user
# DB_PASSWORD = "..." # default: empty
# DB_DATABASE = "..." # default: current user
Run database schema migration:
alembic upgrade head
Run the server with auto-reloading:
python run.py
Try out the API at: http://localhost:8000/docs.
pytest --cov=src --cov=migrations/versions tests
Please note that, the name of the test database is prepended with "test_", you need to create that database too.
Use Docker compose:
docker-compose up
Run database schema migration as well:
docker-compose exec mds poetry run alembic upgrade head
Create test database:
docker-compose exec db createdb -U mds test_mds
Run tests:
docker-compose exec mds poetry run pytest --cov=src --cov=migrations/versions tests
For production, use gunicorn:
gunicorn mds.asgi:app -k uvicorn.workers.UvicornWorker -c gunicorn.conf.py
Or use the Docker image built from the Dockerfile
, using environment variables
with the same name to configure the server.
Other than database configuration, please also set:
DEBUG=0
ADMIN_LOGINS=alice:123,bob:456
Except that, don't use 123
or 456
as the password.