Package: grid2viz
Grid2Viz: The Grid2Op Visualization companion appGrid2Viz is a web application that offers several interactive views into the results of Reinforcement Learning agents that ran on theGrid2Opplatform. It is part of theGridAlivelab ecosystem.0 Demo Gallery1 Documentation2 Installation3 Run the application4 Getting Started5 Caching6 Interface7 Contributing8 Trouble shootingVideo highlighting Grid2viz analyzis capabilitiesThrough this 10-minute video, the  behavior of best AI agents fromL2RPN NeurIPS competitionis analyzed with Grid2viz under a very interesting and tense scenario.Try it out in your browser with HerokuWAnt to reproduce the analysis of the video above !?Give it a try in your own browser through this url:https://grid2viz-neurips.herokuapp.com/Demo GalleryYou can otherwise launch a longer demo in your web navigator by running the Grid2viz_demo notebook through Binder by clicking the Binder button. The[Demo repositories used here presents thebest agent results of NeurIPS 2020 L2RPN Competition.One third IEEE118 region NeurIPS Robustness Track Demo -Demo repositoryhereIEEE118 NeurIPS Adaptability Track Demo -Demo repositoryhere.Documentationgo to:https://grid2viz.readthedocs.io/en/latest/InstallationRequirements:Python >= 3.6(Optional, recommended) Step 1: Create a virtual environmentpip3 install -U virtualenv
python3 -m virtualenv venv_grid2vizStep 2: Install from pypisource venv_grid2viz/bin/activate
pip install -U grid2vizStep 2 (bis): Install from sourcessource venv_grid2viz/bin/activate
git clone https://github.com/rte-france/grid2viz.git
cd grid2Viz/
pip install -URun Grid2Vizusage: grid2viz [-h] [--agents_path AGENTS_PATH] [--env_path ENV_PATH]
                [--port PORT] [--debug]

Grid2Viz

optional arguments:
  -h, --help            show this help message and exit
  --agents_path AGENTS_PATH
                        The path where the episode logs of the Agents to compare are
                        stored. (default to None to study the example agents
                        provided with the package)
  --env_path ENV_PATH   The path where the environment config is stored.
                        (default to None to use the provided default
                        environment)
  --port PORT           The port to serve grid2viz on. (default to 8050)
  --debug               Enable debug mode for developers. (default to False)
  --n_cores             Number of cores to generate cache or load cache faster (default to 1)
  --cache               Create upfront all necessary cache for grid2viz, to avoid waiting for some cache generation online 
  --warm-start          "If True, the application is warm started based on the parameters defined in the WARMSTART section of the config.ini file. (default to False)For example:source venv_grid2viz/bin/activate
grid2viz --port 8000WARNINGDue to the caching operation the first run can take a while. All the agents present in the configuration files
will be computed and then registered in cache. Depending on your agents it could take between 5 to 15min. You can follow the progress in the console.
You can however generate all the cache over all agents and scenarios before end with--cache=Truegrid2viz --port 8000 --agents_path AGENTS_PATH --n_cores Max_Cores --cacheGetting startedIn order to use this tool, you need to have serialized the RL process of grid2op. The expected file system is :root_dir (agents_path)agent_1scenario_1scenario_2agent_2scenario_1scenario_2scenario_3Each of the scenario_* files have to contain all files given by serialisation of your RL through grid2op.
In order to add a new agent to the app, you will have to add the agent's folder to this root_dir
For the update process of this folder chain, see the sectionCaching(in particular, when you want to overwrite the current
agents in root_dir with new versions with the same names)In the config.ini of this repo:agents_diris the path to your agents logs data directory.env_diris the path to the environment configuration directory. It contains a single file :coords.csv : The csv file that lists the coordinates of nodes in the networkChanging this config.ini file will require a restart of the server to update.Grid2Viz provide 2 agents with a scenario for one day and for one month available in/grid2viz/data/agentsfolder:do-nothing-baselinegreedy-baselineBy default the config.ini is targeting these agents as well as the environment configuration folders.CachingThe cache system allows you to only compute long calculations of the app once per agent/scenario.
The app will create a folder_cachein thebase_dirof the config.ini which will contain these long calculations serialized.If you add a new folder in yourbase_dir(either an agent, or a scenario) you will have to restart the server so the app
reads the folder tree again.WARNING: If you overwrite the agents while they were already cached, you will have to manually reset the cache so the app
knows to compute everything again with the updated data. To do so, you just need to delete the_cachefolder.InterfaceScenario SelectionThis page display up to 15 scenarios with for each one a brief summary using the best agent's performances.Scenario OverviewOn this page are displayed the best agent's kpi to see his performances. It's also here that you can select an agent that will
be used as reference agent in the other pages to compare to the studied agents.Agent OverviewHere's displayed your reference agent's performances. You can select an agent to study to compare it with your reference via the
dropdown on the page. The study agent selected will be used as study agent on the last page.In the"instant and cumulated reward"graph you can point timestep that will be use in the next page to study
action in a specific timestep area.Agent StudyThe Agent Study page will display kpi of your reference agent compared to your study agent on your selected timestep area.
You will also see a summary of the previous page's kpi.CONTRIBUTINGAs agent behavior analysis is still an active field of research and new ideas can come along the way, we welcome contributions to develop:new relevant visualizations (within grid2viz/grid2viz/src/kpi)new interactions (see nameOfTab_clbk.py) within the applicationexisting feature improvements are also welcome.Run the testsTo run the tests, execute the following command:python3 -m unittest discover --start-directory tests --bufferLimitationsThe app is still missing a couple features, namely a graph for visualising the flow through time, and the last line of the last screen, which will show all informations regarding the actions and observations at the selected timestep.The Actions KPIs and the distances as well as the topological action cluster "object changed" is in alpha feature. We will need some new features from the core API to finish these features.TroubleshootingMacOSSome mac users have been experimenting issues when lauching the app, raising the following message:socket.gaierror: [Errno 8] nodename nor servname provided, or not knownThe following steps might help you to overcome the issue:Open your terminalTypeecho $HOSTand copy the resultsOpen the file/etc/hostsand make sure you include:127.0.0.1 PASTE RESULTS FROM echo $HOSTSave it and close itLaunch grid2viz