Skip to content

Commit

Permalink
fix app paths to find resources from tests dir
Browse files Browse the repository at this point in the history
  • Loading branch information
northwestwitch committed Apr 15, 2019
1 parent f2bea4a commit f073138
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions patientMatcher/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def demodata(monarch_phenotypes):
click.echo('Adding 50 test patients to database..')
app_root=os.path.abspath(__file__).split('patientMatcher')[0]
path_to_json_patients = os.path.abspath(os.path.join(app_root, 'patientMatcher', 'resources', 'benchmark_patients.json'))
if not os.path.isfile(path_to_json_patients): # running command from tests folder
path_to_json_patients = os.path.abspath(os.path.join(app_root, 'patientMatcher', 'patientMatcher', 'resources', 'benchmark_patients.json'))
inserted_ids = load_demo(path_to_json_data=path_to_json_patients, mongo_db=current_app.db,
host=current_app.config.get('MME_HOST') ,compute_phenotypes=monarch_phenotypes)
click.echo('inserted {} patients into db'.format(len(inserted_ids)))
Expand Down
9 changes: 7 additions & 2 deletions patientMatcher/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ def create_app():
except:
LOG.warning('Environment variable settings not found, configuring from instance file.')
app_root=os.path.abspath(__file__).split('patientMatcher')[0]
LOG.info('app root is: {}'.format(app_root))
app = Flask(__name__, instance_path=os.path.join(app_root, 'patientMatcher', 'instance'), instance_relative_config=True)

# check if config file exists under ../instance:
instance_path = os.path.join(app_root,'patientMatcher', 'instance')
if not os.path.isfile(os.path.join(instance_path,'config.py')): # running app from tests
instance_path = os.path.join(app_root,'patientMatcher','patientMatcher','instance')

app = Flask(__name__, instance_path=instance_path, instance_relative_config=True)
app.config.from_pyfile('config.py')

client = MongoClient(app.config['DB_URI'])
Expand Down

0 comments on commit f073138

Please sign in to comment.