Skip to content

Commit

Permalink
Merge 27f9c7f into 72f3db5
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomas1234 committed Mar 4, 2016
2 parents 72f3db5 + 27f9c7f commit decb17b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 10 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -5,7 +5,7 @@ pandas>=0.15.2
ordered-set==1.2
inspyred==1.0
cobra==0.4.0b6
optlang==0.2.17
optlang==0.2.18
escher==1.0.0
numexpr==2.4
networkx==1.9.1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -33,7 +33,7 @@
'pandas>=0.15.2',
'ordered-set>=1.2',
'cobra==0.4.0b6',
'optlang>=0.2.17',
'optlang>=0.2.18',
'requests>=2.5.0',
'numexpr>=2.4',
'networkx>=1.9.1',
Expand Down
15 changes: 11 additions & 4 deletions tests/test_parallel.py
Expand Up @@ -41,6 +41,11 @@ def interactive(f):
TRAVIS = os.getenv('TRAVIS', False)
SKIP_PARALLEL = TRAVIS

if os.getenv('REDIS_PORT_6379_TCP_ADDR'):
REDIS_HOST = os.getenv('REDIS_PORT_6379_TCP_ADDR') # wercker
else:
REDIS_HOST = 'localhost'

@interactive
def to_the_power_of_2_interactive(arg):
return arg ** 2
Expand Down Expand Up @@ -94,11 +99,13 @@ def test_length(self):

class TestRedisQueue(unittest.TestCase):
def test_queue_size(self):
queue = RedisQueue("test-queue-size-1", maxsize=1)
print(REDIS_HOST)
print(os.getenv('REDIS_PORT_6379_TCP_ADDR'))
queue = RedisQueue("test-queue-size-1", maxsize=1, host=REDIS_HOST)
queue.put(1)
self.assertRaises(six.moves.queue.Full, queue.put, 1)

queue = RedisQueue("test-queue-size-2", maxsize=2)
queue = RedisQueue("test-queue-size-2", maxsize=2, host=REDIS_HOST)
queue.put(1)
queue.put(1)
self.assertRaises(six.moves.queue.Full, queue.put, 1)
Expand All @@ -107,7 +114,7 @@ def test_queue_size(self):
self.assertRaises(six.moves.queue.Empty, queue.get_nowait)

def test_queue_objects(self):
queue = RedisQueue("test-queue", maxsize=100)
queue = RedisQueue("test-queue", maxsize=100, host=REDIS_HOST)
# put int
queue.put(1)
v = queue.get_nowait()
Expand Down Expand Up @@ -140,7 +147,7 @@ def test_queue_objects(self):
self.assertIsInstance(v, dict)

def test_queue_len(self):
queue = RedisQueue("test-queue-len", maxsize=100)
queue = RedisQueue("test-queue-len", maxsize=100, host=REDIS_HOST)
self.assertEqual(queue.length, 0)
queue.put(1)
self.assertEqual(queue.length, 1)
Expand Down
15 changes: 11 additions & 4 deletions tests/test_strain_design_heuristics.py
Expand Up @@ -50,6 +50,11 @@

TRAVIS = os.getenv('TRAVIS', False)

if os.getenv('REDIS_PORT_6379_TCP_ADDR'):
REDIS_HOST = os.getenv('REDIS_PORT_6379_TCP_ADDR') # wercker
else:
REDIS_HOST = 'localhost'

SEED = 1234

CURRENT_PATH = os.path.dirname(__file__)
Expand Down Expand Up @@ -592,21 +597,23 @@ def setUp(self):
self.population = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
self.random = Random(SEED)

# unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost')
def test_migrator_constructor(self):
migrator = MultiprocessingMigrator(max_migrants=1)
migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 1)

migrator = MultiprocessingMigrator(max_migrants=2)
migrator = MultiprocessingMigrator(max_migrants=2, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 2)

migrator = MultiprocessingMigrator(max_migrants=3)
migrator = MultiprocessingMigrator(max_migrants=3, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 3)

# unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost')
def test_migrate_individuals_without_evaluation(self):
migrator = MultiprocessingMigrator(max_migrants=1)
migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 1)

Expand Down
42 changes: 42 additions & 0 deletions wercker.yml
@@ -0,0 +1,42 @@
box:
id: biosustain/cameo-wercker-box
username: $USERNAME
password: $PASSWORD
tag: latest

services:
- redis
build:

steps:

- script:
name: env
code: |
env
- script:
name: run tests for Python 3.4
code: |
source activate cameo3.4
nosetests
codecov --token=$CODECOV_TOKEN
- script:
name: run tests for Python 2.7
code: |
source activate cameo2.7
nosetests
codecov --token=$CODECOV_TOKEN
deploy:

PyPI: # this is triggered if master branch

- script:
name: deploy to PyPI
code: |
source activate cameo3.4
pip install twine
python setup.py sdist
twine upload -u $PYPI_USERNAME -p $PYPI_PASSWD dist/*

0 comments on commit decb17b

Please sign in to comment.