Skip to content

Commit

Permalink
Release fixes (#37)
Browse files Browse the repository at this point in the history
* @cuttlefishh I think these changes cover your observations

* Sanity checking to protect from testing against an unexpected host

* Set the default host

* Oddly need to specify numpy/scipy in a fresh env

* ah, its because biom imports within its setup...
  • Loading branch information
wasade authored and antgonza committed Jun 7, 2017
1 parent 2a5aa1c commit 74893cc
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ install:
- alias md5=md5sum
- pip install -e . --no-deps
script:
- flake8 --ignore=E731 redbiom
- flake8 --ignore=E731 redbiom
- redbiom summarize contexts # will return a nonzero exit status if it cannot communicate with the default host
- export REDBIOM_HOST=http://127.0.0.1:7379
- make test
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ![redbiom](logo.png)
# ![build-status](https://travis-ci.org/wasade/redbiom.svg?branch=master)
# ![build-status](https://travis-ci.org/biocore/redbiom.svg?branch=master)

# What is this?

Expand Down Expand Up @@ -30,9 +30,10 @@ Redbiom depends on [BIOM](http://biom-format.org/) (tested on >= 2.1.5), [Pandas

If you would like to use redbiom as only a client (which is the general case), then the following instructions apply.

$ git clone https://github.com/wasade/redbiom.git
$ git clone https://github.com/biocore/redbiom.git
$ cd redbiom
$ pip install -e .
$ pip install numpy
$ pip install -e .

### Server

Expand All @@ -59,9 +60,14 @@ Webdis packages its dependencies with the exception of libevent. It is entirely

Last, redbiom itself can be installed as a normal Python package.

$ git clone https://github.com/wasade/redbiom.git
$ git clone https://github.com/biocore/redbiom.git
$ pip install numpy
$ pip install -e .

### Testing

The test framework is setup to by default only execute tests against `localhost`, specifically, `127.0.0.1:7379`. However, the repository, by default, is setup to communicate with a remote Webdis server. If you wish to execute the test suite, please `export REDBIOM_HOST=http://127.0.0.1:7379`.

# Terminology and notation

In redbiom, the word "context" refers to a way in which the sample data were processed. Data are loaded into contexts and searches for samples by feature happen within contexts.
Expand Down
2 changes: 1 addition & 1 deletion redbiom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def _close_sessions():
def get_config():
"""Deal with all the configy bits"""
import os
hostname = os.environ.get('REDBIOM_HOST', 'http://127.0.0.1:7379')
hostname = os.environ.get('REDBIOM_HOST', 'http://qiita.ucsd.edu:7329')

return {'hostname': hostname}
12 changes: 12 additions & 0 deletions redbiom/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def assert_test_env():
import os
import redbiom
conf = redbiom.get_config()
if not conf['hostname'].startswith('http://127.0.0.1'):
if not os.environ.get('REDBIOM_OVERRIDE_HOST_AND_TEST', False):
raise ValueError("It appears the REDBIOM_HOST is not 127.0.0.1. "
"By default, the tests will not run on outside "
"of localhost, however if you're sure you want "
"to run the tests against the set host, please "
"set the environment variable "
"REDBIOM_OVERRIDE_HOST_AND_TEST")
2 changes: 2 additions & 0 deletions redbiom/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import redbiom.admin
import redbiom._requests
import redbiom.fetch
from redbiom.tests import assert_test_env

assert_test_env()

table = biom.load_table('test.biom')
table_with_alt = biom.load_table('test_with_alts.biom')
Expand Down
3 changes: 3 additions & 0 deletions redbiom/tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import redbiom.fetch
from redbiom.fetch import (_biom_from_samples, sample_metadata,
sample_counts_per_category)
from redbiom.tests import assert_test_env

assert_test_env()


table = biom.load_table('test.biom')
Expand Down
3 changes: 3 additions & 0 deletions redbiom/tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import redbiom.admin
from redbiom._requests import (valid, _parse_validate_request, _format_request,
make_post, make_get, make_put, buffered)
from redbiom.tests import assert_test_env

assert_test_env()


config = get_config()
Expand Down
3 changes: 3 additions & 0 deletions redbiom/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import json
import numpy as np
import pandas as pd
from redbiom.tests import assert_test_env

assert_test_env()


table = biom.load_table('test.biom')
Expand Down
3 changes: 3 additions & 0 deletions redbiom/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import redbiom._requests
import redbiom.admin
import redbiom.search
from redbiom.tests import assert_test_env

assert_test_env()


metadata = pd.read_csv('test.txt', sep='\t', dtype=str, na_values=[],
Expand Down
3 changes: 3 additions & 0 deletions redbiom/tests/test_summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import redbiom.admin
import redbiom._requests
from redbiom.summarize import contexts
from redbiom.tests import assert_test_env

assert_test_env()


table = biom.load_table('test.biom')
Expand Down
2 changes: 2 additions & 0 deletions redbiom/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
partition_samples_by_tags, resolve_ambiguities,
_stable_ids_from_ambig, _stable_ids_from_unambig,
category_exists, df_to_stems, stems)
from redbiom.tests import assert_test_env

assert_test_env()

table = biom.load_table('test.biom')
table_with_alt = biom.load_table('test_with_alts.biom')
Expand Down
10 changes: 10 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ else
md5=md5sum
fi

# https://stackoverflow.com/a/13864829/19741
if [ ! -z ${REDBIOM_HOST+x} ]; then
if [[ ${REDBIOM_HOST} != *"http://127.0.0.1"* ]]; then
if [ -z ${REDBIOM_OVERRIDE_HOST_AND_TEST+x} ]; then
echo "An unexpected host is set for testing, and \$REDBIOM_OVERRIDE_HOST_AND_TEST is not set"
exit 1
fi
fi
fi

alias md5=md5sum
function md5test ()
{
Expand Down

0 comments on commit 74893cc

Please sign in to comment.