Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
YaphetKG committed Jan 15, 2020
2 parents 6e06428 + 0424988 commit 9ddf29e
Show file tree
Hide file tree
Showing 23 changed files with 1,072 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:

# command to run tests
script:
- pytest -p no:warnings -v greent/test/
- pytest -p no:warnings -vv --cov=greent --cov-report term --cov-config=greent/test/.coveragerc greent/test

#after_success:
# - coveralls
- coveralls
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The above two files should be considered in tandem.
Add unit test cases to greent/test/test_ontology.py
<<<<<<< HEAD
- TO RUN:
$pip install -r greent/requirements.txt
Expand All @@ -45,6 +46,37 @@ pytest -p no:warnings -vv greent/test/test_ontology.py
- Run a single unit test:
pytest greent/test/test_ontology.py -k <test_name>
pytest greent/test/test_ontology.py -k test_label
=======
- TO RUN:
$cd reasoner-tools
$pip install -r greent/requirements.txt
$gunicorn onto_gunicorn:app --workers 1 --pythonpath=$PWD/greent/api
Navigate in your browser to http://127.0.0.1:8000/apidocs.
- TO TEST:
$cd reasoner-tools
Note: If you're running a local server, edit the onto URL in greent/greent.conf to point to 127.0.0.1:8000.
$export greent_conf=greent/greent.conf
$export PYTHONPATH=$PWD:$PWD/greent/api
- To run all unit tests:
pytest greent/test/test_ontology.py
- Remove warnings and get more information as tests run:
pytest -p no:warnings -vv greent/test/test_ontology.py
- Run a single unit test:
pytest greent/test/test_ontology.py -k <test_name>
pytest greent/test/test_ontology.py -k test_label
- Do code coverage for onto:
pytest --cov=greent --cov-report term --cov-config=greent/test/.onto_coveragerc greent/test/test_ontology.py
>>>>>>> 0424988eb5ad9f09bdef9af5574875b96b31848b
```

## BioNames API
Expand Down Expand Up @@ -73,6 +105,7 @@ $pip install -r greent/requirements.txt
$PYTHONPATH=$PWD python3 builder/api/naming.py
- Navigate in your browser to localhost:5000/apidocs.
<<<<<<< HEAD
- TO TEST:
Expand All @@ -87,4 +120,27 @@ pytest -p no:warnings -vv greent/test/test_bionames.py
- Run a single unit test:
pytest greent/test/test_bionames.py -k <test_name>
pytest greent/test/test_bionames.py -k test_lookup_router
=======
- TO TEST:
$cd reasoner-tools
Note: If you're running a local server, edit the bionames URL in greent/greent.conf to point to localhost:5000
$export greent_conf=greent/greent.conf
$export PYTHONPATH=$PWD:$PWD/builder/api
- To run all unit tests:
pytest greent/test/test_bionames.py
- Remove warnings and get more information as tests run:
pytest -p no:warnings -vv greent/test/test_bionames.py
- Run a single unit test:
pytest greent/test/test_bionames.py -k <test_name>
pytest greent/test/test_bionames.py -k test_lookup_router
- Do code coverage for bionames:
pytest --cov=greent --cov-report term --cov-config=greent/test/.bionames_coveragerc greent/test/test_bionames.py
>>>>>>> 0424988eb5ad9f09bdef9af5574875b96b31848b
```
74 changes: 74 additions & 0 deletions bin/bionames
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

################################################################
##
## BioNames is a generic facility which aggregates bio-ontology
## lookup services. It retrieve names from IDs or IDs based
## on Natural Language names.
##
## This is the Bash command line interface (CLI) for BioNames.
##
## author: Chuck Bennett
## version: 0.1
## usage:
##
## exec:
##
## onto exec
## ex: bionames exec
##
## test:
##
## onto test
## ex: bionames test
##
## test_cov:
##
## onto test_cov
## ex: bionames test_cov
##
################################################################
set -e

##
## Configure paths.
##
export CURDIR=$(pwd)
export REASONERTOOLS=${CURDIR%/bin}
export BIONAMES_ROOT=$REASONERTOOLS/builder/api
export GREENT=$REASONERTOOLS/greent
export TESTDIR=$GREENT/test
export PYTHONPATH=$REASONERTOOLS:$BIONAMES_ROOT
export GREENT_CONF=$GREENT/greent.conf

export COVERAGE_DEBUG="sys,config"
export COVERAGE_DEBUG_FILE=$CURDIR/pytestconfig.log

##
## Run the BioNames server
##
exec () {
PYTHONPATH=$PYTHONPATH python3 $BIONAMES_ROOT/naming.py
}

##
## Run tests on the BioNames server.
##
test () {
pytest -p no:warnings -vv $TESTDIR/test_bionames.py
}

##
## Run tests with code coverage.
##
test_cov () {
cd ..
pytest -p no:warnings -vv --cov=$GREENT --cov-report term --cov-config=$TESTDIR/.bionames_coveragerc $TESTDIR/test_bionames.py
# Same test using coverage tool:
#coverage run --rcfile=$TESTDIR/.bionames_coveragerc -m pytest -p no:warnings -vv $TESTDIR/test_bionames.py
#coverage report --rcfile=$TESTDIR/.bionames_coveragerc
}

$*

exit 0
105 changes: 105 additions & 0 deletions bin/comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/bin/bash

export CURDIR=$(pwd)
export REASONERTOOLS=${CURDIR%/bin}
export DOCKER=$REASONERTOOLS/docker

build () {
local mod=$1
if [ -z "$mod" ]; then
echo module name required
fi
docker build --no-cache $DOCKER/$mod -t renciorg/green-$mod
}
push () {
local mod=$1
if [ -z "$mod" ]; then
echo module name required
fi
docker push renciorg/green-$mod
}
clean () {
images () {
for i in $(sudo docker images | awk '{ print $3 }' | grep -vi image); do echo $i; sudo docker rmi -f $i; done
}
$*
}

all () {
build base
push base
build onto_gunicorn
push onto_gunicorn
build bionames
push bionames
}

all_bionames () {
build base
push base
build bionames
push bionames
}

all_onto_gunicorn () {
build base
push base
build onto_gunicorn
push onto_gunicorn
}
kill () {
local mod=$1
if [ -z "$mod" ]; then
echo module name required
fi
docker kill -s 9 $mod
}
shell () {
local mod=$1
if [ -z "$mod" ]; then
echo module name required
fi
docker exec -it $mod bash
}
monit () {
set -x
docker run \
--name monit \
--rm \
renciorg/green-monit-base $*
set +x
}
tranql () {
set -x
docker run \
--name tranql \
--rm \
--publish=8101:8101 \
renciorg/green-tranql
set +x
}
onto_gunicorn () {
set -x
local_dir=$1
docker run \
--env GIT_PULL=true \
--name ont \
--rm \
--publish=5001:5359 \
-v ${local_dir}:/data renciorg/green-onto_gunicorn
set +x
}
bionames () {
set -x
local_dir=$1
docker run \
--env GIT_PULL=true \
--name bio \
--rm \
--publish=5001:5354 \
-v ${local_dir}:/data renciorg/green-bionames
set +x
}


$*
74 changes: 74 additions & 0 deletions bin/onto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

################################################################
##
## Onto aggregates lookup services that provide generic facts
## about ontologies. It leverages the Uberongraph RDB (a
## SPARQL-queried Uberongraph database available at
## https://stars-app.renci.org/uberongraph/#query) for data.
##
## This is the Bash command line interface (CLI) for Onto.
##
## author: Chuck Bennett
## version: 0.1
## usage:
##
## exec:
##
## onto exec
## ex: onto exec
##
## test:
##
## onto test
## ex: onto test
##
## test_cov:
##
## onto test_cov
## ex: onto test_cov
##
################################################################
set -e

##
## Configure paths.
##
export CURDIR=$(pwd)
export REASONERTOOLS=${CURDIR%/bin}
export GREENT=$REASONERTOOLS/greent
export TESTDIR=$GREENT/test
export PYTHONPATH=$GREENT/api:$REASONERTOOLS
export GREENT_CONF=$GREENT/greent.conf

export COVERAGE_DEBUG="sys,config"
export COVERAGE_DEBUG_FILE=$CURDIR/pytestconfig_onto.log

##
## Run the onto gunicorn server
##
exec () {
gunicorn onto_gunicorn:app --workers 1 --pythonpath=$PYTHONPATH
}

##
## Run tests.
##
test () {
pytest -p no:warnings -vv $TESTDIR/test_ontology.py
}

##
## Run tests with code coverage.
##
test_cov () {
cd $REASONERTOOLS
pytest -p no:warnings -vv --cov=$GREENT --cov-report term --cov-config=$TESTDIR/.onto_coveragerc $TESTDIR/test_ontology.py
# Same test using coverage tool:
#coverage run --rcfile=greent/test/.onto_coveragerc -m pytest -p no:warnings -vv greent/test/test_ontology.py
#coverage report --rcfile=greent/test/.onto_coveragerc
}

$*

exit 0
13 changes: 13 additions & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.6.5
ADD . /code
WORKDIR /code

RUN git clone https://github.com/NCATS-Tangerine/reasoner-tools.git

RUN pip install -r reasoner-tools/greent/requirements.txt

RUN apt-get update
RUN apt-get install telnet
RUN apt-get install -y emacs24

CMD ["PYTHONPATH=reasoner-tools", "python", "reasoner-tools/greent/rosetta.py", "--debug", "--test"]
13 changes: 13 additions & 0 deletions docker/bionames/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM renciorg/green-base:latest

ADD ./bionames_smartapi.sh .
ADD ./synonym.py /usr/local/lib/python3.6/site-packages/pronto/synonym.py

RUN chmod +x bionames_smartapi.sh

ENV APP_PORT 5001
ENV NUM_WORKERS 2
ENV DATA_DIR /data
ENV GIT_PULL false

CMD ["./bionames_smartapi.sh"]
Loading

0 comments on commit 9ddf29e

Please sign in to comment.