-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from adamrp/qiita_env_script
Moved the environment control commands
- Loading branch information
Showing
4 changed files
with
117 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |