Skip to content
Snippets Groups Projects
user avatar
Jonathan Seguin authored
f8b1a5e1
History

iric-data

IRIC Data Portal development effort

Clients:

R: https://gitlab.iric.ca/bioinfo_iric/riricdata Python: https://gitlab.iric.ca/bioinfo_iric/pyiricdata

Dependencies

  • Python (> 3.6)
  • PostgreSQL (> 9.4)
  • Node (> 6.12)

New DEV installation

# Clone repo and install pypi packages
cd <somewhere>
git clone git@gitlab.iric.ca:bioinfo_iric/iric-data.git
cd iric-data

# Create a virtenv, py3
module add python/3.6.7
python -m venv .venv

# Activate venv
source .venv/bin/activate
pip install --upgrade pip # update pip version to latest

pip install -r requirements.txt

# Install node modules
module add node
npm install

# run default gulp job to generate CSS/JS resources
gulp
# NB: gulp will keep running in "listening" mode, so open a new shell to keep going
# DB setup
## (login to postgresql server)
CREATE USER iric_data_user WITH PASSWORD 's0me_new_p4ssword';
CREATE DATABASE iric_data_dev;
GRANT ALL PRIVILEGES ON DATABASE iric_data_dev TO iric_data_user;
## Project requires the hstore extension be activated on the project's database
### Need to be admin on postgresql
\c iric_data_dev
CREATE EXTENSION IF NOT EXISTS hstore;
# END DB setup

# update .env to local settings
cp .env.example .env
# Make edits to .env file (including db user passwd !)

Run project locally

# If you need to drop the DB tables
# login postgreSQL server and connect to db
DROP OWNED BY iric_data_user;
# with active virtenv

## Initial deploy:
python manage.py migrate
python manage.py populate_iric

## If NOT initial deploy (safe to run if no migrations exist)
python manage.py migrate portal

# Add initial (super) user
python manage.py createsuperuser

# Run without SSL
python manage.py runserver
# Site is now accessible at:
# http://127.0.0.1:8000

Deploy

git pull origin master
gulp prod
source .venv/bin/activate
python manage.py collectstatic
python manage.py migrate portal
touch iric_data/wsgi.py

Initial Deploy

# as adsoft, setup environment
sudo yum remove mod_wsgi
sudo yum install python34-devel
sudo pip3 install mod_wsgi
sudo mod_wsgi-express install-module
sudoedit /etc/httpd/conf.d/aa.conf

cd /var/www/private
git clone git@gitlab.iric.ca:bioinfo_iric/iric-data.git
cd
python3 -m venv .venv_local
source /var/www/private/iric-data/.venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

module add node
npm install
gulp prod

cp .env.example .env
# edit .env file

python manage.py migrate

sudo systemctl restart httpd

Translations

Make sure your virtual environment is active

django-admin makemessages -l fr
emacs portal/locale/fr/LC_MESSAGES/django.po # (or install gettext extension of choice)
django-admin compilemessages

DB Migrations

Django documentation tl;dr

python manage.py migrate portal [migration_name]

If migration_name is omitted, ALL migrations will be applied. Specify a migration_name to apply migrations up to that one and no further. This can be used to un-apply a migration.

API Endpoints

Returns list of datafiles based on dataset id, key and/or values present in annotation :

  • api/v1/datafiles/list/json/lookup-key/str:key/
  • api/v1/datafiles/list/json/lookup-key/str:key/str:dataset/
  • api/v1/datafiles/list/json/lookup-value/str:value/
  • api/v1/datafiles/list/json/lookup-value/str:value/str:dataset/
  • api/v1/datafiles/list/json/lookup-key-value/str:key/str:value/
  • api/v1/datafiles/list/json/lookup-key-value/str:key/str:value/str:dataset
  • api/v1/datafiles/list/json/lookup-dataset/str:dataset

Returns annotation for given datafile :

  • api/v1/datafiles/json/annotation/int:pk
  • api/v1/datafiles/json/annotation/slug:iric_data_id

Returns metadata for given datafile :

  • api/v1/datafiles/json/metadata/int:pk
  • api/v1/datafiles/json/metadata/slug:iric_data_id

Returns list of datasets :

  • api/v1/admin/str:sim/datasets/list/json/
  • api/v1/my-datasets/list/json/

Links to various resources used in this project

Private Storage PostgreSQL HStore