cathywu / rllab

rllab is a framework for developing and evaluating reinforcement learning algorithms, fully compatible with OpenAI Gym.
Other
1 stars 0 forks source link

Running unittests #3

Closed cathywu closed 7 years ago

cathywu commented 7 years ago

Issue: nose2 installed via pip doesn't seem to run within the virtualenv.

pip install nose2
nosetests tests/test_baselines.py

Tests break on imports:

(rllabcathywu) cathywu:~/Dropbox/PhD/DeepRL-Traffic/rllabcathywu$ nosetests tests/test_baselines.py
E
======================================================================
ERROR: Failure: ImportError (No module named 'theano')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/usr/local/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/local/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/local/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/cathywu/Dropbox/PhD/DeepRL-Traffic/rllabcathywu/tests/test_baselines.py", line 5, in <module>
    from rllab.algos.vpg import VPG
  File "/Users/cathywu/Dropbox/PhD/DeepRL-Traffic/rllabcathywu/rllab/algos/vpg.py", line 1, in <module>
    import theano.tensor as TT
ImportError: No module named 'theano'

----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (errors=1)

But the following works:

(rllabcathywu) cathywu:~/Dropbox/PhD/DeepRL-Traffic/rllabcathywu$ python3
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import theano.tensor as TT
>>>
cathywu commented 7 years ago

This seems to run nosetests within the conda env (as per http://stackoverflow.com/a/864967):

/Users/cathywu/anaconda/envs/rllabcathywu/bin/python /usr/local/bin/nosetests tests/test_baselines.py

New error:

======================================================================
ERROR: tests.test_baselines.test_baseline
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cathywu/anaconda/envs/rllabcathywu/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_baseline() missing 1 required positional argument: 'baseline_cls'

======================================================================
ERROR: tests.test_baselines.test_action_dependent_baseline
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/cathywu/anaconda/envs/rllabcathywu/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
TypeError: test_action_dependent_baseline() missing 1 required positional argument: 'baseline_cls'

----------------------------------------------------------------------
Ran 2 tests in 0.004s

FAILED (errors=2)
cathywu commented 7 years ago

Gives the same error, but shorter command:

/Users/cathywu/anaconda/envs/rllabcathywu/bin/nosetests tests/test_baselines.py
cathywu commented 7 years ago

Oops, the tests are using nose2, not nosetests:

/Users/cathywu/anaconda/envs/rllabcathywu/bin/nose2
/Users/cathywu/anaconda/envs/rllabcathywu/bin/nose2 --coverage=tests/test_baselines.py
cathywu commented 7 years ago

Actually these work fine too:

nose2
nose2 tests.test_baselines
nose2 tests.test_baselines_action