Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Note that this commit ports over the contents of the previously existing
repository.

Fixes qiita-spots#59
  • Loading branch information
ElDeveloper committed Jun 24, 2014
0 parents commit d0ab982
Show file tree
Hide file tree
Showing 109 changed files with 18,139 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# this file is based on the examples provided on scikit-learn's .coveragerc

[run]
omit =
*/test*
*/__init__.py
source = qiita_core,qiita_ware,qiita_db,qiita_pet
branch = True
include = */qiita_*/*

[report]
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
omit =
*/test*
*/__init__.py
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Config files
config.py

# OSX files
.DS_Store

# vi swap and temp files
*.swp
*.swo
*~
34 changes: 34 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
language: python
env:
- PYTHON_VERSION=3.4
- PYTHON_VERSION=2.7
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:$PATH
# Update conda itself
- conda update --yes conda
install:
- conda create --yes -n env_name python=$PYTHON_VERSION pip nose pep8 openpyxl=1.8.2 pandas ipython pyzmq
- source activate env_name
- pip
- pip install coveralls
- pip install .
script:
- ipython profile create qiita_general --parallel
- ipython profile create qiita_demo --parallel
- ipython profile create qiita_reserved --parallel
- qiita_env start_cluster --cluster general
- qiita_env start_cluster --cluster demo
- qiita_env start_cluster --cluster reserved
- qiita_env make_env --env test
- nosetests --with-doctest --with-coverage
- 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
# - coverage run setup.py test
# - coverage report -m
services:
- redis-server
after_success:
- coveralls
54 changes: 54 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Dependencies
------------

Qiita is a python package, with support for python 2.7 and 3.2, that depends on the following python libraries (all of them can be installed using pip):

<!--
* [pgbouncer](http://pgfoundry.org/projects/pgbouncer)
* [IPython](https://github.com/ipython/ipython)
-->

* [tornado 3.1.1](http://www.tornadoweb.org/en/stable/)
* [tornado-redis](https://pypi.python.org/pypi/tornado-redis)
* [Psycopg2](http://initd.org/psycopg/download/)
* [click](http://click.pocoo.org/)
* [NumPy](https://github.com/numpy/numpy)
* [Pandas](http://pandas.pydata.org/)
* [QIIME development version](https://github.com/biocore/qiime)
* [future](http://python-future.org/)
* [bcrypt](https://github.com/pyca/bcrypt/)
* [redis](https://github.com/andymccurdy/redis-py)

And on the following packages:

* [PostgresSQL 9.3](http://www.postgresql.org/download/)
* [redis 2.8.0](https://pypi.python.org/pypi/redis/)

<!--
* [redis-server](http://redis.io)
-->

Install
-------

Once you have [PostgresSQL](http://www.postgresql.org/download/) and [redis](https://pypi.python.org/pypi/redis/) installed (follow the instruction on their web site), simply run these commands to install qiita and configure the demo environment, replacing $QIITA_DIR for the path where qiita is installed
(note that if you are not using Ubuntu you might need to follow the instructions in the next section):

```bash
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_env make_env --env demo
```
## If using other operating systems that are not Ubuntu

You will need to add the postgres user to the database. In order to do this, run:

```bash
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
```
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2013, Qiita development team
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 14 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include README.md
include INSTALL.md
include LICENSE

graft qiita_core
graft qiita_db
graft qiita_pet
graft qitta_ware
graft scripts

global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude *~
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Qiita
=====

[![Build Status](https://travis-ci.org/biocore/qiita.png?branch=master)](https://travis-ci.org/biocore/qiita)
[![Coverage Status](https://coveralls.io/repos/biocore/qiita/badge.png?branch=master)](https://coveralls.io/r/biocore/qiita)

Welcome to Qiita (canonically pronounced *cheetah*) the QIIME databasing effort to enable rapid analysis of microbial ecology datasets. The Qiita repository is responsible for defining the data model and the Python API for interacting with a Qiita database.
4 changes: 4 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test:
adapter: postgresql
database: qiita_test
username: postgres
10 changes: 10 additions & 0 deletions qiita_core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
from __future__ import division

# -----------------------------------------------------------------------------
# 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.
# -----------------------------------------------------------------------------
119 changes: 119 additions & 0 deletions qiita_core/configuration_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# -----------------------------------------------------------------------------
# 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.
# -----------------------------------------------------------------------------

from functools import partial
from os.path import join, dirname, abspath
from os import environ
from future import standard_library
with standard_library.hooks():
from configparser import (ConfigParser, NoOptionError,
MissingSectionHeaderError)


class ConfigurationManager(object):
"""Holds the QIITA configuration
Parameters
----------
conf_fp: str, optional
Filepath to the configuration file. Default: config_test.txt
Attributes
----------
test_environment : bool
If true, we are in a test environment.
base_data_dir : str
Path to the base directorys where all data file are stored
user : str
The postgres user
password : str
The postgres password for the previous user
database : str
The postgres database to connect to
host : str
The host where the database lives
port : int
The port used to connect to the postgres database in the previous host
ipyc_demo : str
The IPython demo cluster profile
ipyc_demo_n : int
The size of the demo cluster
ipyc_reserved : str
The IPython reserved cluster profile
ipyc_reserved_n : int
The size of the reserved cluster
ipyc_general : str
The IPython general cluster profile
ipyc_general_n : int
The size of the general cluster
"""
def __init__(self):
# If conf_fp is None, we default to the test configuration file
try:
conf_fp = environ['QIITA_CONFIG_FP']
except KeyError:
conf_fp = join(dirname(abspath(__file__)),
'support_files/config_test.txt')

# Parse the configuration file
config = ConfigParser()
with open(conf_fp, 'U') as conf_file:
config.readfp(conf_file)

_expected_sections = set(['main', 'ipython', 'redis', 'postgres'])
if set(config.sections()) != _expected_sections:
missing = _expected_sections - set(config.sections())
raise MissingSectionHeaderError("Missing: %r" % missing)

self._get_main(config)
self._get_postgres(config)
self._get_redis(config)
self._get_ipython(config)

def _get_main(self, config):
"""Get the configuration of the main section"""
self.test_environment = config.getboolean('main', 'TEST_ENVIRONMENT')
try:
self.base_data_dir = config.get('main', 'BASE_DATA_DIR')
except NoOptionError as e:
if self.test_environment:
self.base_data_dir = join(dirname(abspath(__file__)),
'../test_data')
else:
raise e

def _get_postgres(self, config):
"""Get the configuration of the postgres section"""
self.user = config.get('postgres', 'USER')
try:
self.password = config.get('postgres', 'PASSWORD')
except NoOptionError as e:
if self.test_environment:
self.password = None
else:
raise e
self.database = config.get('postgres', 'DATABASE')
self.host = config.get('postgres', 'HOST')
self.port = config.getint('postgres', 'PORT')

def _get_redis(self, config):
"""Get the configuration of the redis section"""
pass

def _get_ipython(self, config):
"""Get the configuration of the ipython section"""
sec_get = partial(config.get, 'ipython')
sec_getint = partial(config.getint, 'ipython')

self.ipyc_demo = sec_get('DEMO_CLUSTER')
self.ipyc_reserved = sec_get('RESERVED_CLUSTER')
self.ipyc_general = sec_get('GENERAL_CLUSTER')

self.ipyc_demo_n = sec_getint('DEMO_CLUSTER_SIZE')
self.ipyc_reserved_n = sec_getint('RESERVED_CLUSTER_SIZE')
self.ipyc_general_n = sec_getint('GENERAL_CLUSTER_SIZE')
16 changes: 16 additions & 0 deletions qiita_core/environment_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from IPython.parallel.apps.ipclusterapp import IPClusterStart, IPClusterStop


def start_cluster(profile, n):
"""Start a cluster"""
c = IPClusterStart(profile=profile, log_level=0, daemonize=True)
c.n = n
c.initialize(argv=[])
c.start()


def stop_cluster(profile):
"""Stop a cluster"""
c = IPClusterStop(profile=profile, log_level=0)
c.initialize(argv=[])
c.start()
Loading

0 comments on commit d0ab982

Please sign in to comment.