openai / baselines

OpenAI Baselines: high-quality implementations of reinforcement learning algorithms
MIT License
15.8k stars 4.88k forks source link

pytest fails in bench\test_monitor.py #1070

Open sabibria opened 4 years ago

sabibria commented 4 years ago

All other tests appear to pass but bench\test_monitor.py fails as follows:

E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/baselines-test-e29ffc5a-0bac-4b9f-8f78-e72428b489ec.monitor.csv'

Extended pytest output below. Any idea how to fix this? Running on Windows 10.

F:\Baselines-Reinforcement Learning\baselines-master\baselines>pytest ================================================= test session starts ================================================= platform win32 -- Python 3.7.5, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 rootdir: F:\Baselines-Reinforcement Learning\baselines-master collected 125 items / 1 skipped / 124 selected

bench\test_monitor.py F [ 0%] common\test_mpi_util.py s [ 1%] common\tests\test_cartpole.py ssssss [ 6%] common\tests\test_doc_examples.py s [ 7%] common\tests\test_env_after_learn.py ...... [ 12%] common\tests\test_fixed_sequence.py ss [ 13%] common\tests\test_identity.py ssssssssssssss [ 24%] common\tests\test_mnist.py ssssss [ 29%] common\tests\test_plot_util.py . [ 30%] common\tests\test_schedules.py .. [ 32%] common\tests\test_segment_tree.py ..... [ 36%] common\tests\test_serialization.py .............................. [ 60%] common\tests\test_tf_util.py .. [ 61%] common\tests\envs\identity_env_test.py .. [ 63%] common\vec_env\test_vec_env.py ................s [ 76%] common\vec_env\test_video_recorder.py ........................ [ 96%] ddpg\test_smoke.py .... [ 99%] ppo2\test_microbatches.py . [100%]

================================================================================================================= FAILURES ================================================================================================================= ___ test_monitor ___

def test_monitor():
    import pandas
    import os
    import uuid

    env = gym.make("CartPole-v1")
    env.seed(0)
    mon_file = "/tmp/baselines-test-%s.monitor.csv" % uuid.uuid4()
  menv = Monitor(env, mon_file)

bench\test_monitor.py:13:


bench\monitor.py:20: in init extra_keys=reset_keywords + info_keywords


self = <baselines.bench.monitor.ResultsWriter object at 0x0000015E55B49F08>, filename = '/tmp/baselines-test-e29ffc5a-0bac-4b9f-8f78-e72428b489ec.monitor.csv', header = {'env_id': 'CartPole-v1', 't_start': 1579165501.038712} extra_keys = ()

def __init__(self, filename, header='', extra_keys=()):
    self.extra_keys = extra_keys
    assert filename is not None
    if not filename.endswith(Monitor.EXT):
        if osp.isdir(filename):
            filename = osp.join(filename, Monitor.EXT)
        else:
            filename = filename + "." + Monitor.EXT
  self.f = open(filename, "wt")

E FileNotFoundError: [Errno 2] No such file or directory: '/tmp/baselines-test-e29ffc5a-0bac-4b9f-8f78-e72428b489ec.monitor.csv'

bench\monitor.py:108: FileNotFoundError

futurev commented 4 years ago

I got the same error. anyone has a clue?

futurev commented 4 years ago

I solved it. the hard-coded filename could not be recognized on Window OS, should change "'/tmp/baselines-test-.csv':" into os.path.join("tmp", "baselines-test-.csv", then it worked