Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
Sci test update: easier to run within conda environment
Browse files Browse the repository at this point in the history
 * run.sh - bash script for running python scripts from scripts dir
 * sm-env.sh - export env variable for SM engine
  • Loading branch information
intsco committed May 2, 2016
1 parent 0c6ba6d commit 1b335d4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
6 changes: 6 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/sm-env.sh

python $@
4 changes: 4 additions & 0 deletions scripts/sm-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

export SPARK_HOME=/usr/lib/spark
export PYTHONPATH=$SPARK_HOME/python
3 changes: 2 additions & 1 deletion sm/engine/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@


def proj_root():
return dirname(dirname(dirname(__file__)))
# return dirname(dirname(dirname(__file__)))
return os.getcwd()


dictConfig({
Expand Down
27 changes: 13 additions & 14 deletions tests/sci_test_search_job_spheroid_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@
from sm.engine.db import DB
from sm.engine.util import proj_root, SMConfig

# def sm_config():
# with open(join(proj_root(), 'conf/config.json')) as f:
# return json.load(f)

SMConfig.set_path(join(proj_root(), 'conf/config.json'))
sm_config = SMConfig.get_conf()

ds_name = 'sci_test_spheroid_12h'
data_dir_path = join(SMConfig.get_conf()['fs']['base_path'], ds_name)
input_dir_path = join(proj_root(), 'tests/data/sci_test_search_job_spheroid_dataset')
ds_config_path = join(input_dir_path, 'config.json')

SEARCH_RES_SELECT = ("select sf, adduct, stats "
"from iso_image_metrics s "
Expand Down Expand Up @@ -107,8 +96,8 @@ def clear_data_dirs():

class SciTester(object):

def __init__(self):
self.db = DB(sm_config['db'])
def __init__(self, db_config):
self.db = DB(db_config)
self.base_search_res_path = join(proj_root(), 'tests/reports', 'spheroid_12h_search_res.csv')
self.metrics = ['chaos', 'spatial', 'spectral']

Expand Down Expand Up @@ -140,9 +129,19 @@ def save_sci_test_report(self):
parser = argparse.ArgumentParser(description='Scientific tests runner')
parser.add_argument('-r', '--run', action='store_true', help='compare current search results with previous')
parser.add_argument('-s', '--save', action='store_true', help='store current search results')
parser.add_argument('--sm-config', help='path to sm config file')
args = parser.parse_args()

sci_tester = SciTester()
sm_config_path = args.sm_config if args.sm_config else join(proj_root(), 'conf/config.json')
SMConfig.set_path(sm_config_path)

sm_config = SMConfig.get_conf()
ds_name = 'sci_test_spheroid_12h'
data_dir_path = join(sm_config['fs']['base_path'], ds_name)
input_dir_path = join(proj_root(), 'tests/data/sci_test_search_job_spheroid_dataset')
ds_config_path = join(input_dir_path, 'config.json')

sci_tester = SciTester(sm_config['db'])

if args.run:
try:
Expand Down

0 comments on commit 1b335d4

Please sign in to comment.