matthieu637 / ddrl

Deep Developmental Reinforcement Learning
MIT License
29 stars 3 forks source link

Error about use VScode to dubugging #4

Closed huangjiancong1 closed 5 years ago

huangjiancong1 commented 5 years ago
(clustering) jim@jim-Inspiron-7577:~/ddrl $ cd /home/jim/ddrl ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /home/jim/anaconda2/envs/clustering/bin/python /home/jim/.vscode/extensions/ms-python.python-2019.5.18875/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 37635 /home/jim/ddrl/gym/run.py 
{'load': None, 'view': False, 'save_best': False, 'test_only': False, 'config': 'config.ini', 'render': False, 'capture': False}
Traceback (most recent call last):
  File "/home/jim/.vscode/extensions/ms-python.python-2019.5.18875/pythonFiles/ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "/home/jim/.vscode/extensions/ms-python.python-2019.5.18875/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/jim/.vscode/extensions/ms-python.python-2019.5.18875/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/home/jim/anaconda2/envs/clustering/lib/python3.5/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/jim/anaconda2/envs/clustering/lib/python3.5/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/jim/anaconda2/envs/clustering/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jim/ddrl/gym/run.py", line 59, in <module>
    total_max_steps=int(config['simulation']['total_max_steps'])
  File "/home/jim/anaconda2/envs/clustering/lib/python3.5/configparser.py", line 956, in __getitem__
    raise KeyError(key)
KeyError: 'simulation'

I can run this scripts in the terminal but when debugging in VScode, it have error in this line: total_max_steps=int(config['simulation']['total_max_steps'])

Have you seen this problem before?

I can debug use pdb but vscode is supper powerful than pdb, which IDE you use for debug?

matthieu637 commented 5 years ago

It seems like a problem in your config.ini. You should have a section [simulation]

with a key like

total_max_steps=X

An example of config.ini is given in the readme.

huangjiancong1 commented 5 years ago

I have it in config.ini

[simulation]
total_max_steps=20000000
testing_each=20
#number of trajectories for testing
testing_trials=1
matthieu637 commented 5 years ago

Could you try with the new commit 80c4f6669605e6ce5b876a3219fbb470e8f6b1e1. My guess it that's it can't find your config.ini ?

huangjiancong1 commented 5 years ago

I agree that the VScode debug can't find the config.ini too. Can not solve, it seems that VScode IDE debugging is different with pdb debugging, the return of config.read(clparams[config]) VScode: image

pdb:

> /home/jim/ddrl/gym/run.py(65)<module>()
-> config.read(clparams['config'])
(Pdb) p config.read
config.read         config.read_file    config.readfp
config.read_dict    config.read_string  
(Pdb) p config.read
config.read         config.read_file    config.readfp
config.read_dict    config.read_string  
(Pdb) p config.read(clparams['config'])
['config.ini']
(Pdb) 
matthieu637 commented 5 years ago

You can specify a custom path for the config.ini by using --config while calling run.py

huangjiancong1 commented 5 years ago

Fixed!