# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="sSZjbw6kWch4"
# # WBAP Hackathon 2021
# A google colab friendly notebook. It will allow you to use colab gpu to train your hackathon model from your code in a github repo. 

# + [markdown] id="tm9NDeAhUrCY"
# ## Specify the GitHub repository and branch that you want to run from

# + id="XwPnR2ibNlh2"
branch = 'master'
github_url = 'https://github.com/pulinagrawal/WM_Hackathon'

# + [markdown] id="crY-fJF8UzWl"
# ## Run the cells in this section to setup environment 
# It can take several minutes to run.

# + id="BbsZn_xidsIc" colab={"base_uri": "https://localhost:8080/", "height": 1000} outputId="1806875d-7611-48e5-918c-2a4b5b0db8e0"
# !git clone $github_url
import os
from pathlib import Path
os.chdir(str('WM_Hackathon'))
# !git checkout $branch

# !pip install ray[debug]===0.8.7
# !pip install -r requirements.txt

os.chdir(str(Path('..')))
# !git clone https://github.com/Cerenaut/cerenaut-pt-core 
# !pwd
os.chdir(str(Path('.')/'cerenaut-pt-core'))
# !pwd
# !python setup.py develop
os.chdir(str(Path('..')/'WM_Hackathon'))
# !pwd
# !pip install --ignore-installed --no-deps -e .


# + [markdown] id="crpLmFVqVPf3"
# ### Verify that the installed version of ray is '0.8.7' and your current directory is '/content/WM_Hackathon'

# + colab={"base_uri": "https://localhost:8080/", "height": 35} id="oqM6Ke2QfBSQ" outputId="b4adfb85-8a9f-47e3-8c96-86676a2211ff"
import ray
ray.__version__

# + [markdown] id="44aV6gSgZjW_"
# ## To enable ray to use GPU
# Change to the following config in your agent_av.json
# ```
#  "agent":{
#     "num_workers": 1,
#     "num_gpus": 1,
#     "num_gpus_per_worker": 1,
#     "rollout_fragment_length": 50,
#     "gamma": 0.8
#   }
# ```
#
#

# + colab={"base_uri": "https://localhost:8080/"} id="Ob-HPAVpULmL" outputId="2f82fe4c-4d30-4811-9eec-f8aac1f2a548"
import os
from pathlib import Path
os.chdir('/content/WM_Hackathon')
# !echo Your current directory is
# !pwd

# + [markdown] id="5k3X62AfV-1s"
# # Now you can run train_agent.py with your config

# + colab={"base_uri": "https://localhost:8080/"} id="guWkf0s-gKlG" outputId="7729a230-1361-4b98-9644-62387e549dc9"
# !python train_agent.py m2s-v0 configs/m2s_env.json configs/stub_agent_env_full.json configs/stub_agent_full.json

# + [markdown] id="lE8hgC0KWGbY"
# ## Apologies. Haven't figured out tensorboard yet.
# (This should have technically worked)

# + colab={"base_uri": "https://localhost:8080/", "height": 821} id="b_4Ck7cblmA9" outputId="4340422a-a343-4744-db9d-347426b8942d"
# %reload_ext tensorboard
# %tensorboard --logdir /content/WM_Hackathon/runs

StarcoderdataJupyterScriptsDedupFiltered