SLM Lab As a Python Pip Module
Wen-Wen-Luffy opened this issue · 1 comments
Wen-Wen-Luffy commented
Describe the bug
Can not implement a Session in an external project using the code in the gitbook.
To Reproduce
- OS and environment: MacOS
- SLM Lab git SHA (run
git rev-parse HEAD
to get it): spec
file used: slm_lab/spec/benchmark/ppo/ppo_cartpole.json
Additional context
I replace "from slm_lab.env import OpenAIEnv" to "from slm_lab.env import make_env" line 5
"from slm_lab.experiment.monitor import Body" to "from slm_lab.agent import Body" line 7
"self.env = OpenAIEnv(self.spec)" to "self.env = make_env(self.spec)" line 17
Because previous components can not be found.
Error logs
Traceback (most recent call last):
File "pipex.py", line 56, in <module>
sess = Session(spec)
File "pipex.py", line 18, in __init__
body = Body(self.env, self.spec['agent'])
File "/Users/shiwanyin/SLM-Lab/slm_lab/agent/__init__.py", line 113, in __init__
self.init_tb()
File "/Users/shiwanyin/SLM-Lab/slm_lab/agent/__init__.py", line 132, in init_tb
log_prepath = self.spec['meta']['log_prepath']
TypeError: list indices must be integers or slices, not str
kengz commented
Hi @Wen-Wen-Luffy thanks for spotting this. The code snippet was a bit old. I have updated it to the latest version that is runnable. Please check the page again. Thanks!