Skip to content

Commit

Permalink
Merge pull request #36 from cancervariants/env-keys
Browse files Browse the repository at this point in the history
only use one env var for eb
  • Loading branch information
korikuzma authored Mar 29, 2021
2 parents ee6468d + 6e1562f commit e8e21d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gene/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ def __init__(self, db_url: str = '', region_name: str = 'us-east-2'):
:param str db_url: URL endpoint for DynamoDB source
:param str region_name: default AWS region
"""
if 'GENE_NORM_PROD' in environ.keys():
env_keys = environ.keys()
if 'GENE_NORM_PROD' in env_keys or 'GENE_NORM_EB_PROD' in env_keys:
boto_params = {
'region_name': region_name
}
if 'GENE_NORM_EB_PROD' not in environ.keys():
if 'GENE_NORM_EB_PROD' not in env_keys:
# EB Instance should not have to confirm.
# This is used only for updating production via CLI
if click.confirm("Are you sure you want to use the "
Expand All @@ -31,7 +32,7 @@ def __init__(self, db_url: str = '', region_name: str = 'us-east-2'):
else:
if db_url:
endpoint_url = db_url
elif 'GENE_NORM_DB_URL' in environ.keys():
elif 'GENE_NORM_DB_URL' in env_keys:
endpoint_url = environ['GENE_NORM_DB_URL']
else:
endpoint_url = 'http://localhost:8000'
Expand All @@ -45,7 +46,7 @@ def __init__(self, db_url: str = '', region_name: str = 'us-east-2'):
self.dynamodb_client = boto3.client('dynamodb', **boto_params)

# Create tables if nonexistent if not connecting to production database
if 'GENE_NORM_PROD' not in environ.keys():
if 'GENE_NORM_PROD' not in env_keys:
existing_tables = self.dynamodb_client.list_tables()['TableNames']
self.create_genes_table(existing_tables)
self.create_meta_data_table(existing_tables)
Expand Down

0 comments on commit e8e21d2

Please sign in to comment.