Skip to content

Commit

Permalink
Merge pull request berkeleyflow#43 from berkeleyflow/tune_fix
Browse files Browse the repository at this point in the history
moved scenario so each worker has its own cfg

Fix to autoscaler that enables it to work with tune, as well as the run script. Each scenario has its own cfg
  • Loading branch information
AboudyKreidieh authored Jun 9, 2018
2 parents 4f365b1 + 0a25686 commit 7928af1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
18 changes: 9 additions & 9 deletions flow/utils/rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ def make_create_env(params, version=0, sumo_binary=None):
if sumo_binary is not None:
sumo_params.sumo_binary = sumo_binary

scenario = scenario_class(
name=exp_tag,
generator_class=generator_class,
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config,
traffic_lights=traffic_lights,
)

def create_env(*_):
scenario = scenario_class(
name=exp_tag,
generator_class=generator_class,
vehicles=vehicles,
net_params=net_params,
initial_config=initial_config,
traffic_lights=traffic_lights,
)

sumo_params = deepcopy(params['sumo'])
if sumo_params.port is None:
time_stamp = ''.join(str(time.time()).split('.'))
Expand Down
41 changes: 25 additions & 16 deletions scripts/ray_autoscale.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# cluster.yaml =========================================

# An unique identifier for the head node and workers of this cluster.
cluster_name: eugene #<YOUR NAME>
cluster_name: test #<YOUR NAME>

# The minimum number of workers nodes to launch in addition to the head
# node. This number should be >= 0.
min_workers: 3 #<NUM WORKERS IN CLUSTER>
min_workers: 2 #<NUM WORKERS IN CLUSTER>

# The maximum number of workers nodes to launch in addition to the head
# node. This takes precedence over min_workers.
max_workers: 3
max_workers: 2

# The autoscaler will scale up the cluster to this target fraction of resource
# usage. For example, if a cluster of 10 nodes is 100% busy and
Expand Down Expand Up @@ -41,6 +41,11 @@ auth:
head_node:
InstanceType: m4.16xlarge
ImageId: ami-a2948fc2 # Flow AMI (Ubuntu)
InstanceMarketOptions:
MarketType: spot
#Additional options can be found in the boto docs, e.g.
# SpotOptions:
# MaxPrice: "1.0"

# Additional options in the boto docs.

Expand All @@ -52,29 +57,33 @@ worker_nodes:
InstanceType: m4.16xlarge
ImageId: ami-a2948fc2 # Flow AMI (Ubuntu)

# Run workers on spot by default. Comment this out to use on-demand.
#InstanceMarketOptions:
#MarketType: spot
# Additional options can be found in the boto docs, e.g.
# SpotOptions:
# MaxPrice: MAX_HOURLY_PRICE
#Run workers on spot by default. Comment this out to use on-demand.
InstanceMarketOptions:
MarketType: spot
# Additional options can be found in the boto docs, e.g.
# SpotOptions:
# MaxPrice: "1.0"

# Additional options in the boto docs.

file_mounts: {
# path to your repo and the desired branch name
#"/tmp/foo": "<PATH TO LEARNING TRAFFIC>/.git/refs/heads/<BRANCH NAME>",
#"/tmp/foo2": "<PATH TO RAY_AUTOSCALER_KEY>",
"/tmp/foo": "/Users/eugenevinitsky/Desktop/Research/Bayen/Code/rllab-multiagent/learning-traffic/.git/refs/heads/script_resolution",
"/tmp/foo": "/Users/eugenevinitsky/Desktop/Research/Bayen/Code/rllab-multiagent/learning-traffic/.git/refs/heads/ars_runner",
"/tmp/foo2": "/Users/eugenevinitsky/.ssh/ray-autoscaler_1_us-west-1.pem",
}

setup_commands:
# checkout your desired branch on all worker nodes
# - cd learning-traffic && GIT_SSH_COMMAND="ssh -i ~/ray_bootstrap_key.pem" git fetch
- cd /tmp && cp foo2 ~/ray_autoscaler_key.pem
- cd flow-devel && GIT_SSH_COMMAND="ssh -i ~/ray_autoscaler_key.pem" git fetch && GIT_SSH_COMMAND="ssh -i ~/ray_autoscaler_key.pem" git checkout `cat /tmp/foo`
- cd ray && git fetch eugene_upstream && git checkout HRL_implementation
- cd flow-devel && GIT_SSH_COMMAND="ssh -i ~/ray_autoscaler_key.pem" git fetch && GIT_SSH_COMMAND="ssh -i ~/ray_autoscaler_key.pem" git checkout `cat /tmp/foo`
- cd ray && git fetch eugene_upstream && git checkout add_ars && git pull
- echo 'export PATH="/home/ubuntu/sumo/bin:$PATH"' >> ~/.bashrc
- echo 'export SUMO_HOME="/home/ubuntu/sumo"' >> ~/.bashrc
- echo 'export PYTHONPATH="/home/ubuntu/sumo/tools:$PYTHONPATH"' >> ~/.bashrc
- echo 'export PATH="/home/ubuntu/anaconda3/bin:$PATH"' >> ~/.bashrc
# Custom commands that will be run on the head node after common setup.
head_setup_commands:
- PATH="/home/ubuntu/anaconda3/bin:$PATH" yes | ~/anaconda3/bin/conda install boto3=1.4.8 # 1.4.8 adds InstanceMarketOptions
Expand All @@ -84,10 +93,10 @@ worker_setup_commands: []

# Command to start ray on the head node. You don't need to change this.
head_start_ray_commands:
- PATH="/home/ubuntu/sumo/bin:$PATH" SUMO_HOME="/home/ubuntu/sumo" PYTHONPATH="/home/ubuntu/sumo/tools:$PYTHONPATH" PATH="/home/ubuntu/anaconda3/bin:$PATH" ray stop
- PATH="/home/ubuntu/sumo/bin:$PATH" SUMO_HOME="/home/ubuntu/sumo" PYTHONPATH="/home/ubuntu/sumo/tools:$PYTHONPATH" PATH="/home/ubuntu/anaconda3/bin:$PATH" ray start --head --redis-port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml
- ray stop
- ray start --head --redis-port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml

# Command to start ray on worker nodes. You don't need to change this.
worker_start_ray_commands:
- PATH="/home/ubuntu/sumo/bin:$PATH" SUMO_HOME="/home/ubuntu/sumo" PYTHONPATH="/home/ubuntu/sumo/tools:$PYTHONPATH" PATH="/home/ubuntu/anaconda3/bin:$PATH" ray stop
- PATH="/home/ubuntu/sumo/bin:$PATH" SUMO_HOME="/home/ubuntu/sumo" PYTHONPATH="/home/ubuntu/sumo/tools:$PYTHONPATH" PATH="/home/ubuntu/anaconda3/bin:$PATH" ray start --redis-address=$RAY_HEAD_IP:6379
- ray stop
- ray start --redis-address=$RAY_HEAD_IP:6379
2 changes: 1 addition & 1 deletion scripts/run_rllib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
echo "please pass the name of a script to run"
fi

ray create_or_update ray_autoscale.yaml -y
# ray create_or_update ray_autoscale.yaml -y
# ray2 setup ray_autoscale.yaml
# eval $(ray2 login_cmd ray_autoscale.yaml)
# "cd learning-traffic && python setup.py develop"
Expand Down

0 comments on commit 7928af1

Please sign in to comment.