Thanks to visit codestin.com
Credit goes to github.com

Skip to content

grugna/metadata-service

 
 

Repository files navigation

Metadata Service

Docker release GitHub workflow Coverage Status Dependabot Badge License

The Metadata Service provides API for retrieving JSON metadata of GUIDs.

The server is built with FastAPI and packaged with Poetry.

View API Documentation

Aggregation APIs

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.

Installation

Install required software:

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

Development

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
# USE_AGG_MDS = "..."       # default: false
# AGG_MDS_NAMESPACE = "..." # default: default_namespace
# GEN3_ES_ENDPOINT = "..."  # default: empty

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.

Run tests

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 tests

Develop with Docker

Use Docker compose:

docker-compose up

Run database schema migration as well:

docker-compose exec app alembic upgrade head

Run tests:

docker-compose exec app pytest --cov=src --cov=migrations/versions tests

Deployment

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.

About

The Metadata Service provides API for retrieving JSON metadata of GUIDs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.6%
  • Other 0.4%