Skip to content

Commit

Permalink
Renamed MEGAQC_DEBUG to FLASK_DEBUG and tidied config profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels committed Oct 9, 2018
1 parent 35ca49d commit 95867b3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ uploads/*

# Development stuff
dev.db
test.db
dist/

# Dev CSS
Expand Down
10 changes: 5 additions & 5 deletions docs/installation-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ conda install -c bioconda megaqc
```

## 2. (Optional) Set the variable for the development mode:
Setting this bash variable tells MegaQC to show full Python exception
tracebacks in the web browser, as well as additional Flask plugins
which help with debugging and performance testing.
Setting this bash variable runs MegaQC in development mode. This means
that it will show full Python exception tracebacks in the web browser
as well as additional Flask plugins which help with debugging and performance testing.

This is only useful when actively developing MegaQC code and should
be skipped if you're just trying MegaQC out.

```bash
export MEGAQC_DEBUG=1
export FLASK_DEBUG=1
```

## 3. Set up the database
Running this command creates an empty SQLite MegaQC database file in the
installation directory called `dev.db`.
installation directory called `test.db` (`dev.db` if running in dev mode).

```bash
megaqc initdb
Expand Down
7 changes: 3 additions & 4 deletions megaqc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def update_db_uri(self):
self.SQLALCHEMY_DATABASE
)


class ProdConfig(Config):
"""Production configuration."""

Expand All @@ -83,7 +82,7 @@ def __init__(self):
super(ProdConfig, self).__init__()
self.update_db_uri()
# Log to the terminal
print("Env: Prod")
print(" * Environment: Prod")
print(" * Database type: {}".format(self.SQLALCHEMY_DBMS))
print(" * Database path: {}".format(self.SQLALCHEMY_DATABASE_URI_SAN))

Expand All @@ -107,7 +106,7 @@ def __init__(self):
super(DevConfig, self).__init__()
self.update_db_uri()
# Log to the terminal
print("Env: dev")
print(" * Environment: dev")
print(" * Database type: {}".format(self.SQLALCHEMY_DBMS))
print(" * Database path: {}".format(self.SQLALCHEMY_DATABASE_URI_SAN))

Expand All @@ -126,6 +125,6 @@ def __init__(self):
super(TestConfig, self).__init__()
self.update_db_uri()
# Log to the terminal
print("Env: test")
print(" * Environment: test")
print(" * Database type: {}".format(self.SQLALCHEMY_DBMS))
print(" * Database path: {}".format(self.SQLALCHEMY_DATABASE_URI_SAN))
2 changes: 1 addition & 1 deletion megaqc/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from megaqc.settings import TestConfig, DevConfig, ProdConfig


if os.environ.get('MEGAQC_DEBUG', False):
if os.environ.get('FLASK_DEBUG', False):
CONFIG = DevConfig()
elif os.environ.get('MEGAQC_PRODUCTION', False):
CONFIG = ProdConfig()
Expand Down
8 changes: 7 additions & 1 deletion scripts/megaqc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"""

import click
import os
from flask.cli import FlaskGroup

def create_megaqc_app(info):
import os
from megaqc.app import create_app
from megaqc.settings import TestConfig, DevConfig, ProdConfig

if os.environ.get('MEGAQC_DEBUG', False):
if os.environ.get('FLASK_DEBUG', False):
CONFIG = DevConfig()
elif os.environ.get('MEGAQC_PRODUCTION', False):
CONFIG = ProdConfig()
Expand All @@ -30,4 +31,9 @@ if __name__ == '__main__':
import pkg_resources
version = pkg_resources.get_distribution("megaqc").version
print("This is MegaQC v{}\n".format(version))
if os.environ.get('FLASK_DEBUG', False):
print(' * Environment variable FLASK_DEBUG is true - running in dev mode')
os.environ['FLASK_ENV'] = 'dev'
elif not os.environ.get('MEGAQC_PRODUCTION', False):
os.environ['FLASK_ENV'] = 'test'
cli()

0 comments on commit 95867b3

Please sign in to comment.