aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-01-28 13:38:24 +0530
committerArun Isaac2022-01-28 13:38:24 +0530
commitfadf0b836d512c9839f91df77f5f957e7aca6a1c (patch)
treee726798cf2dd409c464f35ed244863a2b96efd9f
parent2b629077ba1ec52233c118707d44dca2fb5e6afb (diff)
downloadgenenetwork2-fadf0b836d512c9839f91df77f5f957e7aca6a1c.tar.gz
Revert "bin: Set GN2_PROFILE from GUIX_ENVIRONMENT."
This reverts commit f4e336eb1ea526156e112cff97a3ec8137a2bc90.
-rw-r--r--README.md17
-rwxr-xr-xbin/genenetwork283
2 files changed, 63 insertions, 37 deletions
diff --git a/README.md b/README.md
index 7b4fc01f..52382c98 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ genenetwork2
A quick example is
```sh
-env SERVER_PORT=5300 \
+env GN2_PROFILE=~/opt/gn-latest SERVER_PORT=5300 \
GENENETWORK_FILES=~/data/gn2_data/ \
GN_PROXY_URL="http://localhost:8080"\
GN3_LOCAL_URL="http://localhost:8081"\
@@ -69,16 +69,19 @@ We are building 'Mechanical Rob' automated testing using Python
which can be run with:
```sh
-env ./bin/genenetwork2 \
+env GN2_PROFILE=~/opt/gn-latest \
+ ./bin/genenetwork2 \
GN_PROXY_URL="http://localhost:8080" \
GN3_LOCAL_URL="http://localhost:8081 "\
./etc/default_settings.py -c \
../test/requests/test-website.py -a http://localhost:5003
```
-The ./bin/genenetwork2 script sets up the environment and executes
-test-website.py in a Python interpreter. The -a switch says to run all
-tests and the URL points to the running GN2 http server.
+The GN2_PROFILE is the Guix profile that contains all
+dependencies. The ./bin/genenetwork2 script sets up the environment
+and executes test-website.py in a Python interpreter. The -a switch
+says to run all tests and the URL points to the running GN2 http
+server.
#### Unit tests
@@ -99,9 +102,9 @@ runcmd coverage html
The `runcmd` and `runpython` are shell aliases defined in the following way:
```sh
-alias runpython="env TMPDIR=/tmp SERVER_PORT=5004 GENENETWORK_FILES=/gnu/data/gn2_data/ GN_PROXY_URL="http://localhost:8080" GN3_LOCAL_URL="http://localhost:8081" ./bin/genenetwork2
+alias runpython="env GN2_PROFILE=~/opt/gn-latest TMPDIR=/tmp SERVER_PORT=5004 GENENETWORK_FILES=/gnu/data/gn2_data/ GN_PROXY_URL="http://localhost:8080" GN3_LOCAL_URL="http://localhost:8081" ./bin/genenetwork2
-alias runcmd="time env TMPDIR=//tmp SERVER_PORT=5004 GENENETWORK_FILES=/gnu/data/gn2_data/ GN_PROXY_URL="http://localhost:8080" GN3_LOCAL_URL="http://localhost:8081" ./bin/genenetwork2 ./etc/default_settings.py -cli"
+alias runcmd="time env GN2_PROFILE=~/opt/gn-latest TMPDIR=//tmp SERVER_PORT=5004 GENENETWORK_FILES=/gnu/data/gn2_data/ GN_PROXY_URL="http://localhost:8080" GN3_LOCAL_URL="http://localhost:8081" ./bin/genenetwork2 ./etc/default_settings.py -cli"
```
Replace some of the env variables as per your use case.
diff --git a/bin/genenetwork2 b/bin/genenetwork2
index f1e04eef..ea5a4f50 100755
--- a/bin/genenetwork2
+++ b/bin/genenetwork2
@@ -5,45 +5,55 @@
#
# Typical usage
#
-# ./bin/genenetwork2 ~/my_settings.py
+# env GN2_PROFILE=~/opt/genenetwork2-phewas ./bin/genenetwork2 ~/my_settings.py
+#
+# Where GN2_PROFILE points to the GNU Guix profile used for deployment.
#
# This will run the GN2 server (with default settings if none
-# supplied).
+# supplied). Typically you need a GNU Guix profile which is set with
+# an environment variable (this profile is dictated by the
+# installation path of genenetwork). Say your profile is in
+# ~/opt/gn-latest-guix
+#
+# env GN2_PROFILE=~/opt/gn-latest ./bin/genenetwork2
+#
+# You can pass in your own settings file, e.g.
+#
+# env GN2_PROFILE=~/opt/gn-latest ./bin/genenetwork2 ~/my_settings.py
#
# To run a maintenance python script with settings (instead of the
# webserver) run from the base-dir with settings file and add that
# script with a -c switch, e.g.
#
-# env TMPDIR=/export/local/home/zas1024/gn2-zach/tmp WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG SERVER_PORT=5002 GENENETWORK_FILES=/export/local/home/zas1024/gn2-zach/genotype_files SQL_URI=mysql://webqtlout:webqtlout@lily.uthsc.edu/db_webqtl ./bin/genenetwork2 ./etc/default_settings.py -c ./maintenance/gen_select_dataset.py
+# env GN2_PROFILE=/usr/local/guix-profiles/gn-latest-20190905 TMPDIR=/export/local/home/zas1024/gn2-zach/tmp WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG SERVER_PORT=5002 GENENETWORK_FILES=/export/local/home/zas1024/gn2-zach/genotype_files SQL_URI=mysql://webqtlout:webqtlout@lily.uthsc.edu/db_webqtl ./bin/genenetwork2 ./etc/default_settings.py -c ./maintenance/gen_select_dataset.py
#
# To run any script in the environment
#
-# ./bin/genenetwork2 ./etc/default_settings.py -cli echo "HELLO WORLD"
+# env GN2_PROFILE=~/opt/gn-latest ./bin/genenetwork2 ./etc/default_settings.py -cli echo "HELLO WORLD"
#
# To get a python REPL(!)
#
-# ./bin/genenetwork2 ./etc/default_settings.py -cli python
+# env GN2_PROFILE=~/opt/gn-latest ./bin/genenetwork2 ./etc/default_settings.py -cli python
#
# For development you may want to run
#
-# env WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG ./bin/genenetwork2
+# env GN2_PROFILE=~/opt/gn-latest WEBSERVER_MODE=DEBUG LOG_LEVEL=DEBUG ./bin/genenetwork2
#
# For staging and production we use gunicorn. Run with something like
# (note you have to provide the server port). Provide a settings file!
#
-# env SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-prod
+# env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-prod
#
# For development use
#
-# env SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-dev
+# env GN2_PROFILE=~/opt/gn-latest-guix SERVER_PORT=5003 ./bin/genenetwork2 ./etc/default_settings.py -gunicorn-dev
#
# For extra flexibility you can also provide gunicorn parameters yourself with something like
#
-# ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:5003 --workers=1 wsgi"
+# env GN2_PROFILE=~/opt/gn-latest-guix ./bin/genenetwork2 ./etc/default_settings.py -gunicorn "--bind 0.0.0.0:5003 --workers=1 wsgi"
SCRIPT=$(realpath "$0")
echo SCRIPT=$SCRIPT
-export GN2_PROFILE=$GUIX_ENVIRONMENT
echo GN2_PROFILE=$GN2_PROFILE
GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT"))
GN2_ID=$(cat /etc/hostname):$(basename $GN2_BASE_DIR)
@@ -91,27 +101,40 @@ fi
export GN2_SETTINGS=$settings # Python
echo GN2_SETTINGS=$settings
-export PATH=$GN2_PROFILE/bin:$PATH
-export PYTHONPATH="$GN2_PROFILE/lib/python3.8/site-packages" # never inject another PYTHONPATH!!
-export R_LIBS_SITE=$GN2_PROFILE/site-library
-export JS_GUIX_PATH=$GN2_PROFILE/share/genenetwork2/javascript
-export GUIX_GTK3_PATH="$GN2_PROFILE/lib/gtk-3.0"
-export GI_TYPELIB_PATH="$GN2_PROFILE/lib/girepository-1.0"
-export XDG_DATA_DIRS="$GN2_PROFILE/share"
-export GIO_EXTRA_MODULES="$GN2_PROFILE/lib/gio/modules"
-export LC_ALL=C # FIXME
-export GUIX_GENENETWORK_FILES="$GN2_PROFILE/share/genenetwork2"
-export PLINK_COMMAND="$GN2_PROFILE/bin/plink2"
-export GEMMA_COMMAND="$GN2_PROFILE/bin/gemma"
-if [ -z $GEMMA_WRAPPER_COMMAND ]; then
- export GEMMA_WRAPPER_COMMAND="$GN2_PROFILE/bin/gemma-wrapper"
+if [ -z $GN2_PROFILE ] ; then
+ echo "WARNING: GN2_PROFILE has not been set - you need the environment, so I hope you know what you are doing!"
+ export GN2_PROFILE=$(dirname $(dirname $(which genenetwork2)))
+ if [ -d $GN2_PROFILE ]; then
+ echo "Best guess is $GN2_PROFILE"
+ fi
+ echo "ERROR: always set GN2_PROFILE"
+ exit 1
+fi
+if [ -z $GN2_PROFILE ]; then
+ read -p "PRESS [ENTER] TO CONTINUE..."
+else
+ export PATH=$GN2_PROFILE/bin:$PATH
+ export PYTHONPATH="$GN2_PROFILE/lib/python3.8/site-packages" # never inject another PYTHONPATH!!
+ export R_LIBS_SITE=$GN2_PROFILE/site-library
+ export JS_GUIX_PATH=$GN2_PROFILE/share/genenetwork2/javascript
+ export GUIX_GTK3_PATH="$GN2_PROFILE/lib/gtk-3.0"
+ export GI_TYPELIB_PATH="$GN2_PROFILE/lib/girepository-1.0"
+ export XDG_DATA_DIRS="$GN2_PROFILE/share"
+ export GIO_EXTRA_MODULES="$GN2_PROFILE/lib/gio/modules"
+ export LC_ALL=C # FIXME
+ export GUIX_GENENETWORK_FILES="$GN2_PROFILE/share/genenetwork2"
+ export PLINK_COMMAND="$GN2_PROFILE/bin/plink2"
+ export GEMMA_COMMAND="$GN2_PROFILE/bin/gemma"
+ if [ -z $GEMMA_WRAPPER_COMMAND ]; then
+ export GEMMA_WRAPPER_COMMAND="$GN2_PROFILE/bin/gemma-wrapper"
+ fi
+ while IFS=":" read -ra PPATH; do
+ for PPART in "${PPATH[@]}"; do
+ if [ ! -d $PPART ] ; then echo "$PPART in PYTHONPATH not valid $PYTHONPATH" ; exit 1 ; fi
+ done
+ done <<< "$PYTHONPATH"
+ if [ ! -d $R_LIBS_SITE ] ; then echo "R_LIBS_SITE not valid "$R_LIBS_SITE ; exit 1 ; fi
fi
-while IFS=":" read -ra PPATH; do
- for PPART in "${PPATH[@]}"; do
- if [ ! -d $PPART ] ; then echo "$PPART in PYTHONPATH not valid $PYTHONPATH" ; exit 1 ; fi
- done
-done <<< "$PYTHONPATH"
-if [ ! -d $R_LIBS_SITE ] ; then echo "R_LIBS_SITE not valid "$R_LIBS_SITE ; exit 1 ; fi
if [ -z $PYTHONPATH ] ; then
echo "ERROR PYTHONPATH has not been set - use GN2_PROFILE!"
exit 1