Skip to content

Commit

Permalink
Merge pull request #115 from adamrp/qiita_env_script
Browse files Browse the repository at this point in the history
Moved the environment control commands
  • Loading branch information
teravest committed Jun 19, 2014
2 parents 28ad6d8 + 6a5c6a5 commit 856b4b5
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 103 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ install:
- pip install coveralls
- pip install .
script:
- qiita_db make_test_env
- qiita_env make_test_env
- nosetests --with-doctest
- pep8 qiita_db qiita_core qiita_pet setup.py
# we need to run the test suite from setup.py for coveralls to grab the info
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Once you have [PostgresSQL](http://www.postgresql.org/download/) and [redis](htt
echo "export QIITA_CONFIG_FP=$QIITA_DIR/qiita_core/support_files/config_demo.txt" >> ~/.bashrc
source ~/.bashrc
pip install https://github.com/biocore/qiita/archive/master.zip
qiita_db make_demo_env
qiita_env make_demo_env
```
## If using other operating systems that are not Ubuntu

Expand All @@ -48,4 +48,4 @@ createuser -s postgres -d
If you receive the following error, you can ignore this step and continue with the qiita installation:
```bash
createuser: creation of new role failed: ERROR: role "postgres" already exists
```
```
101 changes: 1 addition & 100 deletions scripts/qiita_db
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@

import click

from qiita_db.environment_manager import (make_test_environment,
make_production_environment,
drop_test_environment,
clean_test_environment,
make_demo_environment,
drop_demo_environment,
DFLT_BASE_DATA_FOLDER,
DFLT_BASE_WORK_FOLDER)
from qiita_db.commands import make_study_from_cmd


Expand All @@ -26,67 +18,7 @@ def qiita_db():
pass


@click.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the test data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the actively worked on files are stored")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_test_env(base_data_folder, base_work_folder, user, host):
"""Creates a test database environment.
Creates a new database called `qiita_test` tailored for testing purposes
and initializes the `settings` table of such database
"""
make_test_environment(base_data_folder, base_work_folder, user, None, host)


@click.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def clean_test_env(user, host):
"""Cleans the test database environment.
In case that the test database is dirty (i.e. the 'qiita' schema is
present), this cleans it up by dropping the 'qiita' schema.
"""
clean_test_environment(user, None, host)


@click.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def drop_test_env(user, host):
"""Drops the test database environment.
If the `settings` table is modified, the test database environment should
be rebuilt. This command allows to drop the old one.
"""
drop_test_environment(user, None, host)


@click.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the demo data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the actively worked on files are stored")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_production_env():
"""TODO: Not implemented"""
make_production_environment()


@click.command()
@qiita_db.command()
@click.option('--owner', help="The email address of the owner of the study")
@click.option('--title', help="The title of the study")
@click.option('--info', type=click.File(mode='r'),
Expand All @@ -96,36 +28,5 @@ def insert_study_to_db(owner, title, info):
make_study_from_cmd(owner, title, info)


@click.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the test data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the jobs perform the I/O")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_demo_env(base_data_folder, base_work_folder, user, host):
"""Creates a demo database environment"""
make_demo_environment(base_data_folder, base_work_folder, user, None, host)


@click.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def drop_demo_env(user, host):
"""Drops the demo database environment."""
drop_demo_environment(user, None, host)

qiita_db.add_command(make_test_env)
qiita_db.add_command(clean_test_env)
qiita_db.add_command(drop_test_env)
qiita_db.add_command(make_production_env)
qiita_db.add_command(make_demo_env)
qiita_db.add_command(drop_demo_env)
qiita_db.add_command(insert_study_to_db)

if __name__ == '__main__':
qiita_db()
113 changes: 113 additions & 0 deletions scripts/qiita_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env python

# -----------------------------------------------------------------------------
# Copyright (c) 2014--, The Qiita Development Team.
#
# Distributed under the terms of the BSD 3-clause License.
#
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------

import click

from qiita_db.environment_manager import (make_test_environment,
make_production_environment,
drop_test_environment,
clean_test_environment,
make_demo_environment,
drop_demo_environment,
DFLT_BASE_DATA_FOLDER,
DFLT_BASE_WORK_FOLDER)


@click.group()
def qiita_env():
pass


@qiita_env.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the test data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the actively worked on files are stored")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_test_env(base_data_folder, base_work_folder, user, host):
"""Creates a test database environment.
Creates a new database called `qiita_test` tailored for testing purposes
and initializes the `settings` table of such database
"""
make_test_environment(base_data_folder, base_work_folder, user, None, host)


@qiita_env.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def clean_test_env(user, host):
"""Cleans the test database environment.
In case that the test database is dirty (i.e. the 'qiita' schema is
present), this cleans it up by dropping the 'qiita' schema.
"""
clean_test_environment(user, None, host)


@qiita_env.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def drop_test_env(user, host):
"""Drops the test database environment.
If the `settings` table is modified, the test database environment should
be rebuilt. This command allows to drop the old one.
"""
drop_test_environment(user, None, host)


@qiita_env.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the demo data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the actively worked on files are stored")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_production_env():
"""TODO: Not implemented"""
make_production_environment()


@qiita_env.command()
@click.option('--base_data_folder', default=DFLT_BASE_DATA_FOLDER,
help="The folder where the test data files are stored")
@click.option('--base_work_folder', default=DFLT_BASE_WORK_FOLDER,
help="The folder where the jobs perform the I/O")
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def make_demo_env(base_data_folder, base_work_folder, user, host):
"""Creates a demo database environment"""
make_demo_environment(base_data_folder, base_work_folder, user, None, host)


@qiita_env.command()
@click.option('--user', default='postgres',
help="The database user to connect to the database")
@click.option('--host', default='localhost',
help='The host where the database lives')
def drop_demo_env(user, host):
"""Drops the demo database environment."""
drop_demo_environment(user, None, host)


if __name__ == '__main__':
qiita_env()

0 comments on commit 856b4b5

Please sign in to comment.