rte-france / grid2viz

This repository is a tool for visualizing an agent RL process from a grid2op format. It was made though a partnership between RTE and Artelys for the different challengers of the L2RPN RL Challenge.
https://github.com/rte-france/Grid2Op
Mozilla Public License 2.0
43 stars 18 forks source link

Issue in Grid2Viz_demo.ipynb with grid2viz.app_jupyter.app.run_server() #106

Open AvisP opened 1 year ago

AvisP commented 1 year ago

Getting the following error message when trying to run the cell containing app_jup.run_server() in Grid2Viz_demo.ipynb

ValueError                                Traceback (most recent call last)
Cell In [7], line 2
      1 #if you want to run it in the notebook
----> 2 from grid2viz.app_jupyter import app as app_jup
      3 app_jup.run_server(port=8050,mode="inline")#mode="inline",debug=True)
      4 # app_jup.run_server(mode="jupyterlab"

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/grid2viz/app_jupyter.py:28
     21 app = JupyterDash(
     22     __name__, external_stylesheets=[dbc.themes.BOOTSTRAP]
     23 )  # ,server_url="http://127.0.0.1:8050/")
     25 """
     26 Get Imports to create layout and callbacks 
     27 """
---> 28 from grid2viz.main_callbacks import register_callbacks_main
     29 from grid2viz.layout import make_layout as layout
     31 from grid2viz.src.episodes.episodes_clbk import register_callbacks_episodes

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/grid2viz/main_callbacks.py:18
     10 from dash.exceptions import PreventUpdate
     12 """
     13 WARNING :
     14 These imports are mandatory to build the dependance tree and actually add the callbacks to the dash decoration routine
     15 Do not remove !
     16 The "as ..." are also mandatory, other nothing is done.
     17 """
---> 18 from grid2viz.src.overview import overview_lyt as overview
     19 from grid2viz.src.macro import macro_lyt as macro
     20 from grid2viz.src.micro import micro_lyt as micro

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/grid2viz/src/overview/overview_lyt.py:22
     19 import matplotlib.pyplot as plt
     20 import plotly.graph_objects as go
---> 22 from grid2viz.src.manager import (
     23     agent_scenario,
     24     make_episode,
     25     best_agents,
     26     grid2viz_home_directory,
     27     make_network_scenario_overview,
     28 )
     29 from grid2viz.src.utils.constants import DONT_SHOW_FILENAME
     30 from grid2viz.src.utils.layout_helpers import modal, should_help_open

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/grid2viz/src/manager.py:643
    635 """Parsing of agent folder tree"""
    636 agents = sorted(
    637     [
    638         file
   (...)
    641     ]
    642 )
--> 643 meta_json, best_agents, survival_df, attention_df = check_all_tree_and_get_meta_and_best(
    644     agents_dir, agents
    645 )
    646 scenarios = []
    647 scenarios_agent = {}

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/grid2viz/src/manager.py:560, in check_all_tree_and_get_meta_and_best(base_dir, agents)
    557     survival_dic[agent] = survival_dic_agent
    558     attention_dic[agent] = attention_dic_agent
--> 560 survival_df = pd.DataFrame(columns=agents, index=scenarios)
    561 attention_df = pd.DataFrame(columns=agents, index=scenarios)#, dtype=np.int64)
    562 for agent in agents:

File ~/..../venvs/L2PRN/lib/python3.10/site-packages/pandas/core/frame.py:636, in DataFrame.__init__(self, data, index, columns, dtype, copy)
    634 # GH47215
    635 if index is not None and isinstance(index, set):
--> 636     raise ValueError("index cannot be a set")
    637 if columns is not None and isinstance(columns, set):
    638     raise ValueError("columns cannot be a set")

ValueError: index cannot be a set

Issue can be fixed by converting the scenarios set to list index=list(scenarios) on these two lines

https://github.com/rte-france/grid2viz/blob/191f5f0f3f62d0ab8224bb5a84ef18f1fc6ff6be/grid2viz/src/manager.py#L560

https://github.com/rte-france/grid2viz/blob/191f5f0f3f62d0ab8224bb5a84ef18f1fc6ff6be/grid2viz/src/manager.py#L561

marota commented 1 year ago

Which version of pandas where you using ?

AvisP commented 1 year ago

I see that the panda version in 1.5.1