Through this notebook you will be able to launch the Grid2Viz app.
Visiting next the resulting url that is shown will allow you to play with the app in your browser
The jupyter-dash
package makes it easy to develop Plotly Dash apps from the Jupyter Notebook and JupyterLab.
Just replace the standard dash.Dash
class with the jupyter_dash.JupyterDash
subclass.
Click on the jupyter logo on the top left
import os
pkg_root_dir = !pwd
pkg_root_dir=pkg_root_dir[0]
pkg_root_dir
#short demo
#dataset_agent_log_path = os.path.join(pkg_root_dir,"grid2viz", "data", "agents")
#complete demo over some "warm-up" scenarios of NeurIPS robustness track competition
#dataset_agent_log_path=os.path.join(pkg_root_dir,"Grid2viz-dataset", "NeurIPS_1.2.2_week1")
#Best demo over some "test" scenarios of NeurIPS robustness track competition
dataset_agent_log_path=os.path.join(pkg_root_dir,"Grid2viz-dataset-NeurIPS-Robustness", "res_agents")
def create_config(dataset_agent_log_path):
os.environ["GRID2VIZ_ROOT"] = pkg_root_dir
config_path = os.path.join(pkg_root_dir, "config.ini")
CONFIG_FILE_CONTENT = """
# This file have been automatically generated, please do not modify it.
# You can remove it once done with the application.
[DEFAULT]
agents_dir={agents_dir}
env_dir={env_dir}
n_cores={n_cores}
# This file will be re generated to each call of "python -m grid2viz.main"
"""
#complete demo over some "warm-up" scenarios of NeurIPS robustness track competition
agents_dir = dataset_agent_log_path#os.path.join(pkg_root_dir,"Grid2viz-dataset", "NeurIPS_1.2.2_week1")
env_dir = os.path.join(pkg_root_dir,"grid2viz", "data", "env_conf")
n_cores = 2#args.n_cores
with open(config_path, "w") as f:
f.write(CONFIG_FILE_CONTENT.format(agents_dir=agents_dir,
env_dir=env_dir,
n_cores=n_cores))
Writing the config-file to launch the app
create_config(dataset_agent_log_path)
The documentation of the Grid2viz application can be found here: https://grid2viz.readthedocs.io/en/latest/
#!pip install jupyter-dash
NOTE:
We run the following code twice
to actually see the application runnning and get the url where to load the app
#Run it twice sometimes to actually see it runnning and getting the url to go to paly the app
from grid2viz.app_jupyter import app as app_jup
app_jup.run_server()#mode="inline",debug=True)
app_jup.run_server() #you should get the app url as the output of the cell
#if you want to run it in the notebook
#app_jup.run_server(port=8052,mode="inline")#mode="inline",debug=True)
When running in JupyterLab, with the jupyterlab-dash
extension, setting mode="jupyterlab"
will open the app in a tab in JupyterLab.
app.run_server(mode="jupyterlab")