Skip to content

Commit

Permalink
Merge branch 'playground' of https://github.com/mjothy/grid2viz into …
Browse files Browse the repository at this point in the history
…playground
  • Loading branch information
Vincent Renault committed Feb 25, 2020
2 parents 7e5ae82 + b82c1e1 commit 106ec2b
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 60 deletions.
6 changes: 4 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[DEFAULT]
base_dir = /path/to/directory/containing/agents
env_conf_folder = /path/to/directory/containing/environement/infos
#Should be the root directory containing all the agent folders you want to analyse in the app
base_dir = /path/to/directory/containing/agents/
#Should be the root directory containing both prod_share.csv and coords.csv files
env_conf_folder = /path/to/directory/containing/environement/infos/
35 changes: 0 additions & 35 deletions src/assets/loading.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
/* ._dash-loading-callback{
border: 10px solid #e4032e;
border-right-color: #f49600;
border-bottom-color: #e4032e;
border-left-color: #f49600;
border-radius: 50%;
width: 80px;
height: 80px;
animation: slidein 1s, spin 0.7s linear infinite;
position: fixed;
left: calc( 50% - 40px );
top: calc( 50vh - 40px );
z-index: 1000;
background-color: rgba(255, 255, 255, 0.5);
}
@keyframes slidein {
0% {
opacity: 0;
}
90% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
} */

HTML CSS JSResult
EDIT ON
._dash-loading-callback {
position: fixed;
z-index: 100;
Expand Down
2 changes: 1 addition & 1 deletion src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ body {
background-color: rgba(33, 150, 243, 0.1);
color:#2196F3;
border-color:#2196F3;
border-width: 0.5px;
border-width: 1px;
}

.more-info-table {
Expand Down
1 change: 0 additions & 1 deletion src/grid2viz/macro/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# from .macro_lyt import layout as macro_lyt
12 changes: 5 additions & 7 deletions src/grid2viz/macro/macro_clbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
"""
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
import numpy as np
import pandas as pd
import plotly.graph_objects as go

from src.app import app
from ..manager import make_episode
from grid2kpi.episode import observation_model, EpisodeTrace
from grid2kpi.episode import EpisodeTrace
from grid2kpi.episode import actions_model
from src.grid2viz.utils.graph_utils import get_axis_relayout, relayout_callback
from grid2kpi.episode.maintenances import (hist_duration_maintenances)
Expand All @@ -36,7 +34,7 @@ def load_reward_data_scatter(study_agent, relayout_data_store, figure, ref_agent
layout.update(new_axis_layout)
return figure

return make_rewards_ts(study_agent,ref_agent, scenario, layout)
return make_rewards_ts(study_agent, ref_agent, scenario, layout)


@app.callback(
Expand Down Expand Up @@ -77,15 +75,15 @@ def maintenance_duration_hist(study_agent, figure, scenario):
Output("timeseries_table", "data"),
[Input("cumulated_rewards_timeserie", "clickData"),
Input("agent_log_selector", "value")],
[State("timeseries_table", "data"),
[State("timeseries_table", "data"),
State("agent_study", "data")]
)
def add_timestamp(clickData, new_agent, data, agent_stored):
def add_timestamp(click_data, new_agent, data, agent_stored):
if new_agent != agent_stored:
return []
if data is None:
data = []
new_data = {"Timestamps": clickData["points"][0]["x"]}
new_data = {"Timestamps": click_data["points"][0]["x"]}
if new_data not in data:
data.append(new_data)
return data
Expand Down
7 changes: 3 additions & 4 deletions src/grid2viz/macro/macro_lyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def indicator_line(scenario, study_agent):

episode = make_episode(study_agent, scenario)

nb_actions = episode.action_data_table[['action_line', 'action_subs']].sum()
Expand All @@ -25,7 +24,7 @@ def indicator_line(scenario, study_agent):
data=[go.Pie(
labels=["Actions on Lines", "Actions on Substations"],
values=[nb_actions["action_line"], nb_actions["action_subs"]]
)]
)]
)

maintenance_figure = go.Figure(
Expand Down Expand Up @@ -63,7 +62,7 @@ def indicator_line(scenario, study_agent):
html.P(id="indicator_nb_action",
className="border-bottom h3 mb-0 text-right",
children=episode.action_data_table[['action_line', 'action_subs']].sum(
axis=1).sum()),
axis=1).sum()),
html.P(className="text-muted ",
children="Number of Action")
])
Expand Down Expand Up @@ -176,7 +175,7 @@ def inspector_line(study_agent, scenario):
new_episode = make_episode(study_agent, scenario)
cols, data = get_table(new_episode)
figures_distribution = action_distrubtion(new_episode)

return html.Div(className="lineBlock card ", children=[
html.H4("Inspector For Study Agent", style={'margin-left': '-50px'}),
html.Div(className="card-body col row", children=[
Expand Down
2 changes: 0 additions & 2 deletions src/grid2viz/micro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# from .micro_lyt import layout as micro_lyt
# from .micro_clbk import *
3 changes: 0 additions & 3 deletions src/grid2viz/micro/micro_clbk.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import datetime as dt

import pandas as pd
import plotly.graph_objects as go
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
import numpy as np

from src.app import app
from grid2kpi.episode import observation_model
from ..manager import make_episode, prod_types, make_network
from ..utils.graph_utils import relayout_callback, get_axis_relayout
from ..utils import common_graph
Expand Down
1 change: 0 additions & 1 deletion src/grid2viz/micro/micro_lyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import datetime
from collections import namedtuple


from ..manager import make_episode, make_network, best_agents
from ..utils import common_graph

Expand Down
1 change: 0 additions & 1 deletion src/grid2viz/overview/overview_clbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from dash.exceptions import PreventUpdate

from src.app import app
from datetime import datetime
import pandas as pd

from ..utils.graph_utils import relayout_callback, get_axis_relayout
Expand Down
6 changes: 3 additions & 3 deletions src/grid2viz/utils/common_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def action_tooltip(episode_actions):
return tooltip


def make_action_ts(study_agent, ref_agent, scenario, layout_def = None):
def make_action_ts(study_agent, ref_agent, scenario, layout_def=None):
"""
Make the action timeseries trace of study and reference agents.
:param study_agent: studied agent to compare
:param ref_agent: reference agent to compare with
:param scenario:
:param figure: figure on layout page
:param layout_def: layout page
:return: nb action and distance for each agents
"""
ref_episode = make_episode(ref_agent, scenario)
Expand Down Expand Up @@ -246,4 +246,4 @@ def compute_windows_range(episode, center_idx, n_clicks_left, n_clicks_right):
xmin = timestamp_range[0].strftime("%Y-%m-%dT%H:%M:%S")
xmax = timestamp_range[-1].strftime("%Y-%m-%dT%H:%M:%S")

return xmin, xmax
return xmin, xmax
1 change: 1 addition & 0 deletions src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import src.grid2viz.micro.micro_lyt as micro
import src.grid2viz.overview.overview_lyt as overview
import src.grid2viz.overview.overview_clbk as overview_clbk

'''
End Warning
'''
Expand Down

0 comments on commit 106ec2b

Please sign in to comment.