Name: Data Catalog
Goal: Advertise bio-medical projects and their associated datasets
Local installation of development environment and procedure for docker version are described below.
Instances:
This software is behind the following instances:
Python ≥ 3.7
Solr ≥ 8.2
npm ≥ 7.5.6
sudo apt-get install libsasl2-dev libldap2-dev libssl-dev
-
Install python requirements with:
python setup.py install
-
The less compiler needs to be installed to generate the css files.
sudo npm install less -g
-
Create the setting.py file by copying the template:
cp datacatalog/settings.py.template datacatalog/settings.py
-
Modify the setting file (in datacatalog folder) according to your local environment. The SECRET_KEY parameter needs to be filled with a random string. For maximum security, generate it using python:
import os os.urandom(24)
-
Install the npm dependencies with:
cd datacatalog/static/vendor npm ci npm run build
-
Create a solr core
$SOLR_INSTALLATION_FOLDER/bin/solr start $SOLR_INSTALLATION_FOLDER/bin/solr create_core -c datacatalog
-
Back to the application folder, build the assets:
./manage.py assets build
-
Initialize the solr schema:
./manage.py init_index
-
Index the provided studies, projects and datasets:
./manage.py import_entities Dats study ./manage.py import_entities Dats project ./manage.py import_entities Dats dataset
-
[Optional] Automatically generate sitemap while indexing the datasets:
``` ./manage.py import_entities Dats study --sitemap ./manage.py import_entities Dats project --sitemap ./manage.py import_entities Dats dataset --sitemap ```
-
Generate Sitemap:
./manage.py generate_sitemaps
-
[Optional] Extend Index for studies, projects and datasets:
./manage.py extend_entity_index project ./manage.py extend_entity_index study ./manage.py extend_entity_index dataset
-
Run the development server:
./manage.py runserver
The application should now be available under http://localhost:5000
To run the unit tests:
python setup.py test
Note that a different core is used for tests and will have to be created. By default, it should be called datacatalog_test.
Thanks to docker-compose, it is possible to easily manage all the components (solr and web server) required to run the application.
Docker and git must be installed.
(local)
and (web container)
indicate context of execution.
-
First, generate the certificates that will be used to enable HTTPS in reverse proxy. To do so, change directory to
docker/nginx/
and executegenerate_keys.sh
(relies on OpenSSL). If you don't plan to use HTTPS or just want to see demo running, you can skip this (warning - it would cause the HTTPS connection to be unsafe!). -
Then, copy
datacatalog/settings.py.template
todatacatalog/settings.py
. Edit thesettings.py
file to add a random string of characters inSECRET_KEY
. For maximum security use:import os os.urandom(24)
in python to generate this key.
Then build and start the dockers containers by running:
(local) $ docker-compose up --build
That will create a container with datacatalog web application, and a container for solr (the data will be persisted between runs).
-
Then, to create solr cores, execute in another console:
(local) $ docker-compose exec solr solr create_core -c datacatalog (local) $ docker-compose exec solr solr create_core -c datacatalog_test
-
Then, to fill solr data:
(local) $ docker-compose exec web /bin/bash (web container) $ python manage.py init_index (web container) $ python manage.py import_entities Dats study (web container) $ python manage.py import_entities Dats project (web container) $ python manage.py import_entities Dats dataset (PRESS CTRL+D or type: "exit" to exit)
-
The web application should now be available with loaded data via http://localhost and https://localhost with ssl connection (beware that most browsers display a warning or block self-signed certificates)
Docker container keeps the application in the state that it has been when it was built. Therefore, if you change any files in the project, in order to see changes in application the container has to be rebuilt:
docker-compose up --build
If you wanted to delete solr data, you need to run (that will remove any persisted data - you must
redo solr create_core
):
docker-compose down --volumes
The datasets, projects and studies are all defined in the files located in the folder data/imi_projects
. Those files
can me modified to add, delete and modify those entities. After saving the files, rebuild and restart docker-compose
with:
CTLR+D
to stop all the containers
docker-compose up --build
to rebuild and restart the containers
(local) $ docker-compose exec web /bin/bash
(web container) $ python manage.py import_entities Dats study
(web container) $ python manage.py import_entities Dats project
(web container) $ python manage.py import_entities Dats dataset
(PRESS CTRL+D or type: "exit" to exit)
To reindex the entities
In some cases, you might not want Solr and Nginx to run (for example if there are multiple instances of Data Catalog runnning). Then, simply use:
(local) $ docker build . -t "data-catalog"
(local) $ docker run --name data-catalog --entrypoint "gunicorn" -p 5000:5000 -t data-catalog -t 600 -w 2 datacatalog:app --bind 0.0.0.0:5000
Install needed dependencies with:
pip install -r requirements-dev.txt
Configure pre-commit hook for black and flake8:
see https://dev.to/m1yag1/how-to-setup-your-project-with-pre-commit-black-and-flake8-183k
This tool was initially developed as a joint effort among IMI-FAIRplus, IMI-eTRIKS and ELIXIR-Luxembourg. The original code can be found here.