The Metadata Service provides API for retrieving JSON metadata of GUIDs.
The server is built with FastAPI and packaged with Poetry.
The aggregated MDS APIs and scripts copy metadata from one or many metadata services into a single data store. This enables a metadata service to act as a central API for browsing Metadata using clients such as the Ecosystem browser.
The aggregate metadata APIs and migrations are disabled by default unless USE_AGG_MDS=true is specified. The AGG_MDS_NAMESPACE should also be defined for shared Elasticserach environments so that a unique index is used per-instance.
The aggregate cache is built using Elasticsearch. See the docker-compose.yaml file (specifically the aggregate_migration service) for details regarding how aggregate data is populated.
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 shellCreate 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
# USE_AGG_MDS = "..." # default: false
# AGG_MDS_NAMESPACE = "..." # default: default_namespace
# GEN3_ES_ENDPOINT = "..." # default: emptyRun database schema migration:
alembic upgrade headRun the server with auto-reloading:
python run.pyTry out the API at: http://localhost:8000/docs.
Please note that the name of the test database is prepended with "test_", you need to create that database first:
psql
CREATE DATABASE test_metadata;pytest --cov=src --cov=migrations/versions testsUse Docker compose:
docker-compose upRun database schema migration as well:
docker-compose exec app alembic upgrade headRun tests:
docker-compose exec app pytest --cov=src --cov=migrations/versions testsFor production, use gunicorn:
gunicorn mds.asgi:app -k uvicorn.workers.UvicornWorker -c gunicorn.conf.pyOr 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:456Except that, don't use 123 or 456 as the password.