From ec7d4e1198bc8d2f83ce99b41e2084fbce6a0be7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 10 Sep 2016 11:43:21 +0200 Subject: Support for running maintenance scripts so they can pick up all webserver settings Run with ./bin/genenetwork2 ~/my_settings.py -c ./wqflask/maintenance/gen_select_dataset.py --- bin/genenetwork2 | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index d3bf3299..3a8c3ff4 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -1,6 +1,14 @@ #! /bin/bash # -# This will run the GN2 server (with default settings if none supplied). +# This will run the GN2 server (with default settings if none supplied). Pass in +# your own settings file, e.g. +# +# ./bin/genenetwork2 ~/my_settings.py +# +# To run a maintenance script with settings (instead of the webserver) add that with +# a -c switch, e.g. +# +# ./bin/genenetwork2 ~/my_settings.py -c ./wqflask/maintenance/gen_select_dataset.py # # Environment settings can be used to preconfigure as well as a # settings.py file. @@ -18,7 +26,12 @@ echo $GN2_BASE_PATH # Handle settings parameter settings=$1 -if [ -z $settings ]; then settings=$GN2_BASE_PATH/etc/default_settings.py ; fi +if [ -z $settings ]; then + # get default + settings=$GN2_BASE_PATH/etc/default_settings.py +else + shift +fi if [ ! -e $settings ]; then echo "ERROR: can not locate settings file - pass it in the command line" exit 1 @@ -32,7 +45,15 @@ export PYTHONPATH=$GN2_BASE_PATH/wqflask:$PYTHONPATH if [ -z $TEMPDIR ]; then TEMPDIR="/tmp" fi - + +# Now handle command parameter -c +if [ $1 = '-c' ] ; then + echo PYTHONPATH=$PYTHONPATH + echo RUNNING COMMAND $2 + /usr/bin/env python $2 + exit 0 +fi + echo "Starting the redis server:" echo -n "dir $TEMPDIR dbfilename gn2.rdb -- cgit 1.4.1 From f399b3bf514b396de67644d4b1e2018886cecac2 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 13 Sep 2016 09:09:21 +0200 Subject: Run scripts from ./wqflask - just like the webserver --- bin/genenetwork2 | 9 +++++---- wqflask/base/data_set.py | 2 +- wqflask/maintenance/gen_select_dataset.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index 3a8c3ff4..d926d6a1 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -13,13 +13,12 @@ # Environment settings can be used to preconfigure as well as a # settings.py file. -# Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=$(readlink -f "$0") -# Absolute path this script is in, thus /home/user/bin GN2_BASE_PATH=$(dirname $(dirname "$SCRIPT")) GN2_GUIX_PATH=$GN2_BASE_PATH/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg if [ -d $GN2_GUIX_PATH ]; then + echo GN2 is running from GUIX GN2_BASE_PATH=$GN2_GUIX_PATH fi echo $GN2_BASE_PATH @@ -48,9 +47,11 @@ fi # Now handle command parameter -c if [ $1 = '-c' ] ; then + cd $GN2_BASE_PATH/wqflask + cmd=${2#wqflask/} echo PYTHONPATH=$PYTHONPATH - echo RUNNING COMMAND $2 - /usr/bin/env python $2 + echo RUNNING COMMAND $cmd + /usr/bin/env python $cmd exit 0 fi diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 6cd3c8e6..1b4e1195 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -91,7 +91,7 @@ Publish or ProbeSet. E.g. if USE_GN_SERVER: data = menu_main() else: - file_name = "wqflask/wqflask/static/new/javascript/dataset_menu_structure.json" + file_name = "wqflask/static/new/javascript/dataset_menu_structure.json" with open(file_name, 'r') as fh: data = json.load(fh) diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index f2f0830f..23adc4f9 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -40,8 +40,8 @@ from __future__ import print_function, division import sys -# NEW: Note we prepend the current path - otherwise a guix instance of GN2 is used instead -sys.path.insert(0,'./wqflask') +# NEW: Note we prepend the current path - otherwise a guix instance of GN2 may be used instead +sys.path.insert(0,'./') # NEW: import app to avoid a circular dependency on utility.tools from wqflask import app -- cgit 1.4.1 From e8a5cb1fba08f5d35f7392a1f8af54bf8ae65821 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 25 Sep 2016 08:47:03 +0000 Subject: Testing: looking for a way to run pylmm --- bin/test-website | 23 +++++++++++++++-------- test/lib/mapping.rb | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/lib/navigation.rb | 12 +++++------- 3 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 test/lib/mapping.rb (limited to 'bin') diff --git a/bin/test-website b/bin/test-website index 2e91f364..18994cc5 100755 --- a/bin/test-website +++ b/bin/test-website @@ -2,8 +2,8 @@ USAGE = <0 ARGV.shift else @@ -85,8 +89,11 @@ if options[:link_checker] else require 'main_web_functionality' end - + if options[:navigation_test] require 'navigation' end +if options[:mapping_test] + require 'mapping' +end diff --git a/test/lib/mapping.rb b/test/lib/mapping.rb new file mode 100644 index 00000000..08b6b5da --- /dev/null +++ b/test/lib/mapping.rb @@ -0,0 +1,51 @@ +# In these tests we navigate from the main page to a specific trait then hit the different mapping tool buttons (In this case pylMM and r/qtl) followed by computing the results (marker regressions). + + +class MappingTest +end + +describe MappingTest do + before do + @agent = Mechanize.new + @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt' + end + + describe MappingTest do + it "pyLMM mapping tool selection" do + url = $host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P' + page = @agent.get(url) + # get the form + # form = @agent.page.form_with(:name => "my-form") + # get the button you want from the form + # page.forms.each do |form| + # p form + # end + # button = page.button_with(:value => "pylmm_compute") + # submit the form using that button + # agent.submit(form, button) + # link = page.link_with(text: 'pyLMM') + # page = link.click + # puts page.uri + # link = page.link_with(text: 'Compute') + # page = link.click + # puts page.uri + # probe_link.uri.to_s.must_equal "/marker_regression" + end + end + +end + +describe MappingTest do + it "R/qtl mapping tool selection" do + break if $options[:skip_broken] + page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P') + link = page.link_with(text: 'R/qtl') + page = link.click + puts page.uri + form.field_with(:name => 'Methods').options[2].select + link = page.link_with(text: 'Compute') + page = link.click + puts page.uri + probe_link.uri.to_s.must_equal "/marker_regression" + end +end diff --git a/test/lib/navigation.rb b/test/lib/navigation.rb index 676ee90c..ee9f41d2 100644 --- a/test/lib/navigation.rb +++ b/test/lib/navigation.rb @@ -1,16 +1,16 @@ # In these tests we navigate from the main page to a specific trait then hit the different mapping tool buttons (In this case pylMM and r/qtl) followed by computing the results (marker regressions). -class NavigationTest +class MappingTest end -describe NavigationTest do +describe MappingTest do before do @agent = Mechanize.new @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt' end - describe NavigationTest do + describe MappingTest do it "pyLMM mapping tool selection" do break if $options[:skip_broken] page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P') @@ -27,7 +27,7 @@ describe NavigationTest do end -describe NavigationTest do +describe MappingTest do it "R/qtl mapping tool selection" do break if $options[:skip_broken] page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P') @@ -38,8 +38,6 @@ describe NavigationTest do link = page.link_with(text: 'Compute') page = link.click puts page.uri - probe_link.uri.to_s.must_equal "/marker_regression" + probe_link.uri.to_s.must_equal "/marker_regression" end end - - -- cgit 1.4.1