Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #29

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ RUN mkdir -p /root/.mujoco && \
COPY README.md /root/code/roam_rl/README.md
COPY roam_rl/__init__.py /root/code/roam_rl/roam_rl/__init__.py
COPY setup.py /root/code/roam_rl/setup.py
COPY Makefile /root/code/roam_rl/Makefile
WORKDIR /root/code/roam_rl

# Create virtualenv
Expand All @@ -86,11 +85,14 @@ RUN pip install --upgrade pip
# We need a MuJoCo key to install mujoco_py
# In this step only the presence of the file mjkey.txt is required, so we only
# create an empty file
RUN touch /root/.mujoco/mjkey.txt && \
pip install mujoco_py && \
make default && \
rm -r /root/.cache/pip && \
rm /root/.mujoco/mjkey.txt
RUN touch /root/.mujoco/mjkey.txt && pip install mujoco_py && rm /root/.mujoco/mjkey.txt && \
pip uninstall --yes tensorflow tensorflow-gpu && pip install tensorflow==1.14 && \
pip install git+https://[email protected]/roamlab/confac@master#egg=confac && \
pip install git+https://[email protected]/roamlab/roam_env@master#egg=roam_env && \
pip install --force-reinstall git+https://[email protected]/openai/baselines@master#egg=baselines && \
pip install --force-reinstall git+https://[email protected]/roamlab/baselines-hippo@master#egg=baselines-hippo && \
pip install -e . && \
rm -r /root/.cache/pip

COPY . /root/code/roam_rl/

Expand Down
96 changes: 0 additions & 96 deletions Dockerfile.garage

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default: test-env
make common

# dependencies for baselines, we use garage's well maintained setup script
setup:
setup:
if [ -d "tmp" ]; then\
rm -rf tmp;\
fi
Expand All @@ -27,7 +27,7 @@ test-env:
exit 1;\
fi

common:
common:
pip install git+https://[email protected]/roamlab/confac@master#egg=confac
pip install git+https://[email protected]/roamlab/roam_env@master#egg=roam_env
pip install --force-reinstall git+https://[email protected]/openai/baselines@master#egg=baselines
Expand Down
1 change: 1 addition & 0 deletions roam_rl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .ppo import PPO
5 changes: 0 additions & 5 deletions roam_rl/baselines/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions roam_rl/baselines/hippo.py

This file was deleted.

1 change: 0 additions & 1 deletion roam_rl/baselines/utils/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion roam_rl/garage/__init__.py

This file was deleted.

122 changes: 0 additions & 122 deletions roam_rl/garage/sac.py

This file was deleted.

26 changes: 14 additions & 12 deletions roam_rl/baselines/ppo.py → roam_rl/ppo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
from confac import make
from baselines.common import set_global_seeds
from baselines.ppo2 import ppo2
from baselines import logger
from roam_rl.baselines.utils import VecEnvMaker
from roam_rl.baselines.models import get_network
from roam_rl.utils.vec_env_maker import VecEnvMaker
from roam_rl.utils.models import get_network
from gym import spaces
import numpy as np
from roam_rl import utils
from roam_rl.utils import path_utils
from roam_rl.utils import config_utils

class PPO:

Expand All @@ -30,12 +30,14 @@ def __init__(self, config, section):

# env
env_maker_section = config.get(section, 'env_maker')
self.env_maker = make(config, env_maker_section)
self.env_maker = config_utils.initfromconfig(config, env_maker_section)
vec_env_maker_section = config.get(section, 'vec_env_maker')
self.vec_env_maker = VecEnvMaker(config, vec_env_maker_section)

self.seed = config.getint(section, 'seed')

self.info_keywords = eval(config.get(section, 'info_keywords', fallback='()'))

def _get_parameter_descr_dict(self):

"""
Expand Down Expand Up @@ -67,17 +69,17 @@ def train(self, model_path=None):

# Create vec env
set_global_seeds(self.seed)
logdir = utils.get_log_dir(self.experiment_dir, self.seed) # setup ppo logging
logdir = path_utils.get_log_dir(self.experiment_dir, self.seed) # setup ppo logging
logger.configure(dir=logdir, format_strs=['stdout', 'log', 'csv', 'tensorboard'])
monitor_file_path = os.path.join(logdir, 'monitor.csv')
env = self.vec_env_maker(self.env_maker, self.seed, monitor_file=monitor_file_path)
env = self.vec_env_maker(self.env_maker, self.seed, monitor_file=monitor_file_path, info_keywords=self.info_keywords)

# Learn
# pylint: disable=E1125
model = self._learn(env=env, **self.params, seed=self.seed, load_path=model_path) # learn model
model = self._learn(env=env, **self.params, seed=self.seed, load_path=model_path, extra_keys=self.info_keywords) # learn model

# Save
model.save(utils.get_model_path(self.experiment_dir, self.seed))
model.save(path_utils.get_model_path(self.experiment_dir, self.seed))
env.close()

def set_experiment_dir(self, dir_name):
Expand All @@ -92,7 +94,7 @@ def load(self, model_seed, model_checkpoint=None, env_seed=0, monitor_file=None)

# train for 0 timesteps to load
self.params['total_timesteps'] = 0
model_path = utils.get_model_path(self.experiment_dir, model_seed, model_checkpoint)
model_path = path_utils.get_model_path(self.experiment_dir, model_seed, model_checkpoint)
# pylint: disable=E1125
model = self._learn(env=env, **self.params, load_path=model_path)
return model, env
Expand All @@ -101,10 +103,10 @@ def run(self, model, env, stochastic=False):
""" """
obs = env.reset()
_states = None
# after training stochasticity of the policy is not relevant,
# after training stochasticity of the policy is not relevant,
# set the actions to be mean of the policy
if not stochastic:
model.act_model.action = model.act_model.pi
model.act_model.action = model.act_model.pi

def determinstic_action(pi):
if isinstance(env.action_space, spaces.Box):
Expand Down
1 change: 1 addition & 0 deletions roam_rl/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading