Skip to content

Commit

Permalink
Merge pull request #55 from ola-t/fix_run_filters
Browse files Browse the repository at this point in the history
fix study filter on runs
  • Loading branch information
atarkowska committed Feb 23, 2018
2 parents 7976eb8 + da403df commit b082a83
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 139 deletions.
35 changes: 9 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,28 @@ python:
- '3.6'

env:
- VENV=miniconda
- VENV=virtualenv
- EMG_CONFIG=$TRAVIS_BUILD_DIR/travis/config.yaml

services:
- docker
- mysql
- mongodb

before_install:
- pip install "flake8==3.4" pycodestyle pep8-naming
- python setup.py sdist
- mysql -e 'CREATE DATABASE emg;'
- python -V

install:
# UnsatisfiableError: The following specifications were found to be in conflict:
# - python 3.4*
# - urllib3 -> ipaddress -> python 2.7*
- if [[ "$VENV" == "miniconda" && "$TRAVIS_PYTHON_VERSION" != "3.4" ]]; then
SRCDIR=$(pwd) PYTHON_VERSION=$TRAVIS_PYTHON_VERSION docker/run.sh install;
fi
- pip install "flake8==3.4" pycodestyle pep8-naming
- python setup.py sdist
- pip install "git+git://github.com/ola-t/django-rest-framework-json-api@develop#egg=djangorestframework-jsonapi"

before_script:
- docker --version
# travis by default comes with MySQL 5.5
- sudo service mysql stop
- docker run --rm --name mysql -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5.6
# optional redis
# - docker run --rm --name redis -p 6379:6379 -d redis
- flake8 --version
- flake8 -v .
- mkdir -p ~/emg && cp travis/config.yaml ~/emg/

script:
- if [[ "$VENV" == "miniconda" ]]; then
SRCDIR=$(pwd) docker/run.sh travis_conda;
else
SRCDIR=$(pwd) docker/run.sh travis;
fi

after_script:
- docker stop mysql #redis
- pip install -U .
- python setup.py test

notifications:
slack:
Expand Down
8 changes: 0 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ Create configuration file in `~/path/to/config.yaml <docker/config.yaml>`_.
Install
-------

Install Miniconda::

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

export PATH=~/miniconda/bin:$PATH


Install application::

pip install "git+git://github.com/ola-t/django-rest-framework-json-api@develop#egg=djangorestframework-jsonapi"
Expand Down
6 changes: 5 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ RUN yum -y update; yum clean all

RUN yum -y install epel-release gcc bzip2 git wget; yum clean all

RUN yum -y install python34 python34-devel python34-setuptools
RUN easy_install-3.4 pip
RUN pip3 install -U pip virtualenv setuptools

# Install mysql tools
RUN yum -y install mysql mysql-devel

Expand All @@ -23,4 +27,4 @@ WORKDIR /home/emg

RUN mkdir -p $HOME/emg

ENTRYPOINT ["/tmp/docker/run.sh", "docker"]
ENTRYPOINT ["/tmp/docker/run.sh"]
13 changes: 7 additions & 6 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: mysql:5.6
volumes:
# - ./mysql:/var/lib/mysql:rw
- ../database/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro
- ../schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- MYSQL_DATABASE=emg
Expand All @@ -19,18 +19,19 @@ services:
- ../docker/config.yaml:/home/emg/emg/config.yaml:ro
links:
- mysql
- redis
- mongodb
environment:
- PYTHONUNBUFFERED=0

nginx:
image: nginx:1.10
image: nginx:1.12
links:
- app
volumes:
- ../nginx/conf.d:/etc/nginx/conf.d
- ../nginx/conf.d:/etc/nginx/conf.d:ro
- ../results:/results:ro
ports:
- "80:80"

redis:
image: redis
mongodb:
image: mongo:3.4
111 changes: 21 additions & 90 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,33 @@

set -eux

entryPoint=${1:-}
srcDir=${SRCDIR:-"${HOME}/src"}
condaDir=${CONDADIR:-"${HOME}/miniconda"}
pythonVer=${PYTHON_VERSION:-"3.6"}
venvDir=${VENVDIR:-"${HOME}/venv"}

check_conda() {
if [[ -f "/etc/profile.d/conda.sh" ]]; then
command -v conda >/dev/null && echo "conda detected in $PATH"
fi;
conda info
conda search "^python$"
}

create_venv() {
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
/bin/bash miniconda.sh -b -p $condaDir
export PATH=$condaDir/bin:$PATH
rm -rf miniconda.sh
hash -r
conda install python=${pythonVer} -y
# conda update -q conda
conda info -a
python -V

# TODO: wait until 4.4 https://github.com/conda/conda/issues/3200
#conda create -q -n test-environment python=$pythonVer
#source activate test-environment

}

is_db_running() {
local conn=${1:-};

echo "DB startup..."
until mysql $conn -e 'show databases;'; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 5
done
>&2 echo "MySQL now accepts connections, creating database..."
}

install_src() {
echo "Installing EMG API..."
pip install "git+git://github.com/ola-t/django-rest-framework-json-api@develop#egg=djangorestframework-jsonapi"
pip install -U $srcDir
}

start() {
echo "EMG API Start up..."

# emgcli check --deploy
emgcli migrate --fake-initial
emgcli collectstatic --noinput

# development server
# emgcli runserver 0.0.0.0:8000
emgdeploy -p ${HOME}/emg/emg.pid --bind 0.0.0.0:8000 --workers 5 --reload emgcli.wsgi:application

}


# helpers
install() {
create_venv
python -V
}
rm -f $srcDir/var/django.pid

install_docker() {
install
pip install -U "django-redis>=4.4"
is_db_running "-u root -h mysql -P 3306"
}
python3 -V

docker() {
install_docker
install_src
start
}
virtualenv -p /usr/bin/python3 $venvDir --system-site-packages
# $HOME/venv/bin/pip install -U "django-redis>=4.4"

travis() {
# Install source, otherwise OSError: [Errno 2] No such file or directory.
install_src
cd $srcDir
python -V
python setup.py test
}
echo "Installing EMG API..."
$venvDir/bin/pip install -U "git+git://github.com/ola-t/django-rest-framework-json-api@develop#egg=djangorestframework-jsonapi"
$venvDir/bin/pip install -U $srcDir

travis_conda() {
export PATH=$condaDir/bin:$PATH
# Install source, otherwise OSError: [Errno 2] No such file or directory.
travis
}
echo "DB startup..."
until mysql -u root -h mysql -P 3306 -e 'show databases;'; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 5
done
>&2 echo "MySQL now accepts connections, creating database..."

echo "EMG API Start up..."

rm -f $srcDir/var/django.pid
# $HOME/venv/bin/emgcli check --deploy
# $venvDir/bin/emgcli migrate --fake-initial
$venvDir/bin/emgcli collectstatic --noinput

if [ ! -z ${entryPoint} ] ; then
eval $entryPoint
fi
# development server
# $HOME/venv/bin/emgcli runserver 0.0.0.0:8000
$venvDir/bin/emgdeploy -p $HOME/emg/emg.pid --bind 0.0.0.0:8000 --workers 5 --reload emgcli.wsgi:application
2 changes: 1 addition & 1 deletion emgapi/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def filter_sample_accession(self, qs, name, value):
help_text='Study accession')

def filter_study_accession(self, qs, name, value):
return qs.filter(sample__studies__accession=value)
return qs.filter(study__accession=value)

# include
include = django_filters.CharFilter(
Expand Down
18 changes: 12 additions & 6 deletions emgapianns/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,11 @@ class AnalysisGoTermRelationshipViewSet( # NOQA
def get_queryset(self):
accession = self.kwargs['accession']
release_version = self.kwargs['release_version']
qs = emg_models.AnalysisJob.objects.exclude(
experiment_type__experiment_type='amplicon')
job = get_object_or_404(
emg_models.AnalysisJob, accession=accession,
pipeline__release_version=release_version
qs, accession=accession,
pipeline__release_version=release_version,
)

analysis = None
Expand Down Expand Up @@ -297,9 +299,11 @@ class AnalysisGoSlimRelationshipViewSet( # NOQA
def get_queryset(self):
accession = self.kwargs['accession']
release_version = self.kwargs['release_version']
qs = emg_models.AnalysisJob.objects.exclude(
experiment_type__experiment_type='amplicon')
job = get_object_or_404(
emg_models.AnalysisJob, accession=accession,
pipeline__release_version=release_version
qs, accession=accession,
pipeline__release_version=release_version,
)

analysis = None
Expand Down Expand Up @@ -334,9 +338,11 @@ class AnalysisInterproIdentifierRelationshipViewSet( # NOQA
def get_queryset(self):
accession = self.kwargs['accession']
release_version = self.kwargs['release_version']
qs = emg_models.AnalysisJob.objects.exclude(
experiment_type__experiment_type='amplicon')
job = get_object_or_404(
emg_models.AnalysisJob, accession=accession,
pipeline__release_version=release_version
qs, accession=accession,
pipeline__release_version=release_version,
)

analysis = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_requirements = os.path.join(_base, 'requirements.txt')
_requirements_test = os.path.join(_base, 'requirements-test.txt')

version = "1.0.6"
version = "1.0.7"

install_requirements = []
with open(_requirements) as f:
Expand Down

0 comments on commit b082a83

Please sign in to comment.