From 94a2c9d73ceb1a5f73376b25f632f45ffdcb5374 Mon Sep 17 00:00:00 2001 From: mjothy Date: Tue, 25 Feb 2020 14:09:22 +0100 Subject: [PATCH 1/2] pep8 inspection --- src/assets/loading.css | 35 -------------------------- src/assets/main.css | 2 +- src/grid2viz/macro/__init__.py | 1 - src/grid2viz/macro/macro_clbk.py | 12 ++++----- src/grid2viz/macro/macro_lyt.py | 7 +++--- src/grid2viz/micro/__init__.py | 2 -- src/grid2viz/micro/micro_clbk.py | 3 --- src/grid2viz/micro/micro_lyt.py | 2 -- src/grid2viz/overview/overview_clbk.py | 1 - src/grid2viz/utils/common_graph.py | 6 ++--- src/index.py | 1 + 11 files changed, 13 insertions(+), 59 deletions(-) diff --git a/src/assets/loading.css b/src/assets/loading.css index 80fa971..974adb3 100644 --- a/src/assets/loading.css +++ b/src/assets/loading.css @@ -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; diff --git a/src/assets/main.css b/src/assets/main.css index 6b964f5..c64231a 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -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 { diff --git a/src/grid2viz/macro/__init__.py b/src/grid2viz/macro/__init__.py index 92bce5a..e69de29 100644 --- a/src/grid2viz/macro/__init__.py +++ b/src/grid2viz/macro/__init__.py @@ -1 +0,0 @@ -# from .macro_lyt import layout as macro_lyt \ No newline at end of file diff --git a/src/grid2viz/macro/macro_clbk.py b/src/grid2viz/macro/macro_clbk.py index 19e57ad..271664b 100644 --- a/src/grid2viz/macro/macro_clbk.py +++ b/src/grid2viz/macro/macro_clbk.py @@ -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) @@ -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( @@ -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 diff --git a/src/grid2viz/macro/macro_lyt.py b/src/grid2viz/macro/macro_lyt.py index 4712532..c3b7e0f 100644 --- a/src/grid2viz/macro/macro_lyt.py +++ b/src/grid2viz/macro/macro_lyt.py @@ -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() @@ -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( @@ -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") ]) @@ -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=[ diff --git a/src/grid2viz/micro/__init__.py b/src/grid2viz/micro/__init__.py index 4213690..e69de29 100644 --- a/src/grid2viz/micro/__init__.py +++ b/src/grid2viz/micro/__init__.py @@ -1,2 +0,0 @@ -# from .micro_lyt import layout as micro_lyt -# from .micro_clbk import * \ No newline at end of file diff --git a/src/grid2viz/micro/micro_clbk.py b/src/grid2viz/micro/micro_clbk.py index 822ec9a..43bcfaa 100644 --- a/src/grid2viz/micro/micro_clbk.py +++ b/src/grid2viz/micro/micro_clbk.py @@ -1,14 +1,11 @@ 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 import grid2viz.utils.common_graph from src.app import app -from grid2kpi.episode import observation_model from ..manager import make_episode, prod_types, make_network from src.grid2viz.utils.graph_utils import relayout_callback, get_axis_relayout import grid2viz.utils.common_graph as common_graph diff --git a/src/grid2viz/micro/micro_lyt.py b/src/grid2viz/micro/micro_lyt.py index a448553..f41c274 100644 --- a/src/grid2viz/micro/micro_lyt.py +++ b/src/grid2viz/micro/micro_lyt.py @@ -6,10 +6,8 @@ import datetime from collections import namedtuple - import grid2viz.utils.common_graph from ..manager import make_episode, make_network, best_agents -from ..utils import common_graph layout_def = { 'legend': {'orientation': 'h'}, diff --git a/src/grid2viz/overview/overview_clbk.py b/src/grid2viz/overview/overview_clbk.py index cc6296c..2b3bd54 100644 --- a/src/grid2viz/overview/overview_clbk.py +++ b/src/grid2viz/overview/overview_clbk.py @@ -2,7 +2,6 @@ from dash.exceptions import PreventUpdate from src.app import app -from datetime import datetime import pandas as pd from src.grid2viz.utils.graph_utils import relayout_callback, get_axis_relayout diff --git a/src/grid2viz/utils/common_graph.py b/src/grid2viz/utils/common_graph.py index eec0df8..070e503 100644 --- a/src/grid2viz/utils/common_graph.py +++ b/src/grid2viz/utils/common_graph.py @@ -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) @@ -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 \ No newline at end of file + return xmin, xmax diff --git a/src/index.py b/src/index.py index 6f5ae59..5df42e7 100644 --- a/src/index.py +++ b/src/index.py @@ -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 ''' From b82c1e1a73cd3e250666ca129b157384e25a924d Mon Sep 17 00:00:00 2001 From: mjothy Date: Tue, 25 Feb 2020 14:14:08 +0100 Subject: [PATCH 2/2] commented the conf file --- config.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config.ini b/config.ini index ea42a23..b7d84e1 100644 --- a/config.ini +++ b/config.ini @@ -1,3 +1,5 @@ [DEFAULT] -base_dir = /path/to/directory/containing/agents -env_conf_folder = /path/to/directory/containing/environement/infos \ No newline at end of file +#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/ \ No newline at end of file