A web interface for the scoring of biomedical digital objects by user evaluation according to the FAIR data principles: Findability, Accessibility, Interoperability, and Reusability.
Available at http://fairshake.cloud/
Python 3 is required to run this project.
Install all dependencies into your environment.
pip install -r requirements.txt
Note that mysqlclient
is the recommended client but pymysql
can be used as a fallback.
To render the page properly in development, it's necessary to collect staticfiles so they can be hosted by django.
./manage.py collectstatic
# Run in debugging mode, show errors and host staticfiles locally
export DEBUG=1
# Specify location of mysql config file for production database
export MYSQL_CONFIG=$(pwd)/config/my.cnf
ipython is recommended: pip install ipython
./manage.py shell
In separate terminals execute these commands and then navigate to http://localhost:8000/.
./manage.py runserver
./manage.py livereload
docker-compose build
Django keeps track of database migrations. When modifying models
it is imperative to create and apply migrations on all old databases. Migrations can be safely removed if they have been applied to all independent databases (for that reason, it's probably better to just not remove them).
./manage.py makemigrations
./manage.py migrate
Note that this will try but not always succeed to detect renamed fields and such and migrate the backend database accordingly. If it is unable to, it may require manual intervention. For more information https://docs.djangoproject.com/en/2.0/topics/migrations/.
# Run Tests
./manage.py test
# Run Tests with Coverage
coverage run --source='.' manage.py test && coverage report
# Backup data, omit django internals (which could cause loading to fail)
./manage.py dumpdata \
-e contenttypes \
-e admin \
-e auth.Permission \
--natural-foreign \
--indent=2 \
> mybackup.json
# Ensure database is initialized
./manage.py migrate
# Load data from backup
./manage.py loaddata mybackup.json
For the docker-compose to work properly in production, /config/
should have the following files:
my.cnf
: mysql configuration file with production database credentials
MYSQL_CONFIG
environment variablesecret.txt
: Secret key for production (random private string of characters)cert.key
: SSL Private Key (optional, for https)cert.crt
: SSL CA Signed Public Key (optional, for https)Can be configured by the administrator here. If using gmail, ensure you allow less secure apps.
docker-compose up
Errors involving mysql trying to load from /tmp/sock arrise when MYSQL_CONFIG
environment variable is being read, but the file on the other end is problematic.
export MYSQL_CONFIG=$(pwd)/ssl/my.cnf
cat $MYSQL_CONFIG
chmod 644 ssl/my.cnf
before trying again.In general, if the database has changed (and there are new migration files), if you're running a local database you may need to apply new migrations with ./manage.py migrate
.
If the cache table doesn't yet exist, you can create it with ./manage.py createcachetable
.
First try re-executing pip install -r requirements.txt
.
In the worst case you may need to rebuild your environment from nothing (starting from scratch, and installing dependencies again).
I recommend pyenv
for managing isolated python environments.