From 0ffb90047615d5b49d66c2f690e51cc52ac54f15 Mon Sep 17 00:00:00 2001 From: DanSava Date: Tue, 3 Dec 2024 11:08:26 +0200 Subject: [PATCH] Run ruff formating --- .github/workflows/style.yml | 55 ++++++++++++++----- .gitignore | 2 +- CODE_OF_CONDUCT.md | 2 +- README.md | 2 +- SECURITY.md | 2 +- docs/installing_everviz.rst | 4 +- docs/introduction.rst | 2 +- docs/running_everviz.rst | 2 +- everviz/components/list_select.py | 9 ++- everviz/config.py | 11 ++-- everviz/everest_hooks.py | 7 ++- everviz/log.py | 2 +- everviz/pages/configuration.py | 3 +- everviz/pages/controls.py | 3 +- everviz/pages/deltaplot.py | 3 +- everviz/pages/gradientplot.py | 3 +- everviz/pages/objectives.py | 1 + everviz/pages/summary_values.py | 1 - everviz/pages/wells_values.py | 2 +- everviz/plugins/__init__.py | 24 ++++---- .../best_controls_plot/best_controls_plot.py | 7 +-- .../plugins/config_editor/config_editor.py | 5 +- .../plugins/controls_plot/controls_plot.py | 8 +-- everviz/plugins/crossplot/crossplot.py | 9 ++- .../plugins/crossplot/crossplot_indexed.py | 10 ++-- everviz/plugins/delta_plot/delta_plot.py | 8 +-- everviz/plugins/gradient_plot.py | 14 ++--- .../objectives_plot/objectives_plot.py | 10 ++-- .../objectives_plot/single_objectives_plot.py | 8 +-- everviz/plugins/objectives_plot/util.py | 2 +- everviz/plugins/plugin_abc.py | 3 +- .../plugins/summary_plot/summary_callback.py | 2 +- everviz/plugins/summary_plot/summary_plot.py | 9 ++- everviz/plugins/summary_plot/util.py | 2 +- everviz/plugins/summary_plot/wells_plot.py | 10 ++-- .../plugins/utils/layout/sidebar_layout.py | 3 +- everviz/util.py | 2 +- tests/conftest.py | 6 +- .../config_editor/test_config_editor.py | 3 +- .../test_crossplot_indexed_integration.py | 5 +- .../crossplot/test_crossplot_integration.py | 2 +- .../test_objectives_delta_plot_integration.py | 2 +- .../test_summary_delta_plot_integration.py | 3 +- .../test_gradient_plot_integration.py | 1 - .../test_objectives_plot_integration.py | 2 +- .../test_summary_plot_integration.py | 3 +- .../test_well_plot_integration.py | 3 +- .../test_indexed_crossplot_layout.py | 8 +-- tests/unit/crossplot/test_layout.py | 11 ++-- tests/unit/test_control_plot_data.py | 10 ++-- tests/unit/test_delta_plot_data.py | 1 - tests/unit/test_everviz_config.py | 5 +- tests/unit/test_get_indexed_control.py | 1 - tests/unit/test_gradient_plot_data.py | 8 +-- tests/unit/test_objective_plot_data.py | 9 +-- .../unit/test_single_objective_plot_layout.py | 9 ++- tests/unit/test_summary_callback.py | 7 +-- tests/unit/test_summary_plot.py | 5 +- tests/unit/test_util.py | 3 +- 59 files changed, 185 insertions(+), 174 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 444914a..d9c65c2 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -1,20 +1,45 @@ -name: style +name: Style -on: [pull_request] +on: + push: + branches: + - main + - 'version-**' + pull_request: + +env: + UV_SYSTEM_PYTHON: 1 + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - lint_and_black: + check-style: + timeout-minutes: 15 runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12'] + steps: - - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: 3.12 - - name: Install everviz with style dependencies - run: | - pip install ".[style]" - - name: Run style check - run: | - ruff . - black --check . + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Install ERT with style dependencies + run: | + uv pip install ".[style]" + + - name: Run style check + if: ${{ always() }} + run: | + SKIP=no-commit-to-branch pre-commit run --all-files --show-diff-on-failure diff --git a/.gitignore b/.gitignore index 5870dbb..fdc79cf 100644 --- a/.gitignore +++ b/.gitignore @@ -137,4 +137,4 @@ dmypy.json .pyre/ # pytype static type analyzer -.pytype/ \ No newline at end of file +.pytype/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 2e84704..120a368 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -16,7 +16,7 @@ In addition to any definition or interpretation of the open source code of condu If at any point concerns are raised that a group or member is not acting according to our values, the behaviour in question should cease, be discussed, and tried to be resolved. -We expect everyone to have a low threshold for raising issues, or in general discuss how we live up to our values. +We expect everyone to have a low threshold for raising issues, or in general discuss how we live up to our values. Equally, we encourage all community members to appreciate when concerns are raised and do their best to solve them. Project maintainers are responsible both for *what* is delivered, as well as *how* it is delivered. diff --git a/README.md b/README.md index 9ed787a..f1bd650 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ # everviz: web based visualization for everest ## What is everviz -everviz is a visualization plugin for everest based on [dash](https://github.com/plotly/dash) +everviz is a visualization plugin for everest based on [dash](https://github.com/plotly/dash) and [webviz-config](https://github.com/equinor/webviz-config). ## Download project diff --git a/SECURITY.md b/SECURITY.md index 73c39d3..ea3ba1e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,4 +13,4 @@ The following information will help us triage your report more quickly: - Proof-of-concept or exploit code (if possible) - Impact of the issue, including how an attacker might exploit the issue -We prefer all communications to be in English. \ No newline at end of file +We prefer all communications to be in English. diff --git a/docs/installing_everviz.rst b/docs/installing_everviz.rst index 47e8464..f7dd702 100644 --- a/docs/installing_everviz.rst +++ b/docs/installing_everviz.rst @@ -1,7 +1,7 @@ ****************** Installing Everviz ****************** -*Everviz* is a plugin of *Everest*, and therefore *Everest* must be installed in the same Python enviroment before you install *Everviz*. +*Everviz* is a plugin of *Everest*, and therefore *Everest* must be installed in the same Python enviroment before you install *Everviz*. *Everviz* is based on `Webviz `_, which must be installed before installing *Everviz*. @@ -19,4 +19,4 @@ If you want to download the latest source code and install it manually use the f cd ./everviz pip install . -After installation *Everviz* can be started from the *Everest* tool. \ No newline at end of file +After installation *Everviz* can be started from the *Everest* tool. diff --git a/docs/introduction.rst b/docs/introduction.rst index 808e3b9..f0771a7 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -4,4 +4,4 @@ Introduction *Everviz* is a plugin for *Everest* that enables plotting of the results of an optimization. The *Everest* tool is designed for optimizing well drilling order and time under geological uncertainty. The results of the optimization include control and function values, as they evolve during the optimization. In addition, the simulators that are used in the optimization process produce various time series of summary values at each iteration, each of which may involve multiple simulation runs. -*Everviz* is designed to plot the control, function and summary values produced during the optimization run. *Everviz* is based on `Webviz `_, a *Dash*-based tool for creating plotting applications using `yaml` configuration files. \ No newline at end of file +*Everviz* is designed to plot the control, function and summary values produced during the optimization run. *Everviz* is based on `Webviz `_, a *Dash*-based tool for creating plotting applications using `yaml` configuration files. diff --git a/docs/running_everviz.rst b/docs/running_everviz.rst index d9a5b3b..a5f181c 100644 --- a/docs/running_everviz.rst +++ b/docs/running_everviz.rst @@ -30,4 +30,4 @@ Cross plots allow you to plot any arbitrary value in the optimization resuls aga Everviz configuration ===================== -This page shows the configuration file that is used to generate all the plots. \ No newline at end of file +This page shows the configuration file that is used to generate all the plots. diff --git a/everviz/components/list_select.py b/everviz/components/list_select.py index 88a3c21..5313756 100644 --- a/everviz/components/list_select.py +++ b/everviz/components/list_select.py @@ -1,11 +1,10 @@ from typing import List -import dash - -from dash.development.base_component import Component -from dash.dependencies import Output, Input, State -from dash import html, dcc +import dash import webviz_core_components as wcc +from dash import dcc, html +from dash.dependencies import Input, Output, State +from dash.development.base_component import Component def layout(uuid: str, default_options: List[str] = None) -> Component: diff --git a/everviz/config.py b/everviz/config.py index 49b217b..70462ea 100644 --- a/everviz/config.py +++ b/everviz/config.py @@ -1,18 +1,19 @@ import os + import yaml from everviz.log import get_logger -from everviz.util import get_everviz_folder, DEFAULT_CONFIG from everviz.pages import ( - controls, configuration, + controls, crossplot, - summary_values, - objectives, deltaplot, - wells_values, gradientplot, + objectives, + summary_values, + wells_values, ) +from everviz.util import DEFAULT_CONFIG, get_everviz_folder logger = get_logger() diff --git a/everviz/everest_hooks.py b/everviz/everest_hooks.py index edf68ac..6e1671b 100644 --- a/everviz/everest_hooks.py +++ b/everviz/everest_hooks.py @@ -1,13 +1,14 @@ -import subprocess +import os import shutil import signal +import subprocess import sys -import os from everest.plugins import hookimpl # pylint: disable=import-error -from everviz.util import get_everviz_folder + from everviz.config import setup_default_everviz_config from everviz.log import setup_logger +from everviz.util import get_everviz_folder def handle_exit(*args): # pylint: disable=unused-argument) diff --git a/everviz/log.py b/everviz/log.py index dbc175e..221899e 100644 --- a/everviz/log.py +++ b/everviz/log.py @@ -1,6 +1,6 @@ import logging -import sys import os +import sys def _formatter(): diff --git a/everviz/pages/configuration.py b/everviz/pages/configuration.py index c09b121..2d6af57 100644 --- a/everviz/pages/configuration.py +++ b/everviz/pages/configuration.py @@ -1,5 +1,6 @@ import os -from everviz.util import get_everviz_folder, DEFAULT_CONFIG + +from everviz.util import DEFAULT_CONFIG, get_everviz_folder def page_layout(api): diff --git a/everviz/pages/controls.py b/everviz/pages/controls.py index cbb8e4c..26d36d2 100644 --- a/everviz/pages/controls.py +++ b/everviz/pages/controls.py @@ -1,8 +1,9 @@ import os from collections import namedtuple + import pandas as pd -from everviz.log import get_logger +from everviz.log import get_logger DataSources = namedtuple("DataSource", "controls_per_batch, controls_initial_vs_best") diff --git a/everviz/pages/deltaplot.py b/everviz/pages/deltaplot.py index 6cc5d29..83d3615 100644 --- a/everviz/pages/deltaplot.py +++ b/everviz/pages/deltaplot.py @@ -1,8 +1,9 @@ import os from collections import namedtuple + import pandas as pd -from everviz.log import get_logger +from everviz.log import get_logger DataSources = namedtuple( "DataSource", ["objective_delta_values", "summary_delta_values"] diff --git a/everviz/pages/gradientplot.py b/everviz/pages/gradientplot.py index bffb7a1..9e6e18e 100644 --- a/everviz/pages/gradientplot.py +++ b/everviz/pages/gradientplot.py @@ -1,8 +1,9 @@ import os from collections import namedtuple + import pandas as pd -from everviz.log import get_logger +from everviz.log import get_logger DataSources = namedtuple("DataSource", "gradient_values") diff --git a/everviz/pages/objectives.py b/everviz/pages/objectives.py index 72bc5e3..8729468 100644 --- a/everviz/pages/objectives.py +++ b/everviz/pages/objectives.py @@ -1,5 +1,6 @@ import os from collections import namedtuple + import pandas as pd from everviz.log import get_logger diff --git a/everviz/pages/summary_values.py b/everviz/pages/summary_values.py index 3ab8384..c01469d 100644 --- a/everviz/pages/summary_values.py +++ b/everviz/pages/summary_values.py @@ -3,7 +3,6 @@ from everviz.log import get_logger - DataSources = namedtuple("DataSource", ["summary_values"]) logger = get_logger() diff --git a/everviz/pages/wells_values.py b/everviz/pages/wells_values.py index 7af006e..53f4e2e 100644 --- a/everviz/pages/wells_values.py +++ b/everviz/pages/wells_values.py @@ -6,7 +6,7 @@ WELLS_EXPLANATION = """ The well plot requires well summary data to be loaded from the forward model. Make sure the wells are specified in the Everest config file and exported from -Eclipse/Flow to *.UNSMRY. To visualize target rates they also need to be added +Eclipse/Flow to *.UNSMRY. To visualize target rates they also need to be added to the simulator summary data section. """ diff --git a/everviz/plugins/__init__.py b/everviz/plugins/__init__.py index f1da636..8b8f073 100644 --- a/everviz/plugins/__init__.py +++ b/everviz/plugins/__init__.py @@ -1,25 +1,25 @@ +from everviz.plugins.best_controls_plot.best_controls_plot import BestControlsPlot +from everviz.plugins.config_editor.config_editor import ConfigEditor +from everviz.plugins.controls_plot.controls_plot import ControlsPlot from everviz.plugins.crossplot.crossplot import Crossplot from everviz.plugins.crossplot.crossplot_indexed import CrossplotIndexed -from everviz.plugins.summary_plot.summary_plot import SummaryPlot -from everviz.plugins.objectives_plot.objectives_plot import ObjectivesPlot -from everviz.plugins.objectives_plot.single_objectives_plot import SingleObjectivesPlot -from everviz.plugins.controls_plot.controls_plot import ControlsPlot -from everviz.plugins.best_controls_plot.best_controls_plot import BestControlsPlot from everviz.plugins.delta_plot.delta_plot import DeltaPlot from everviz.plugins.gradient_plot import GradientPlot -from everviz.plugins.config_editor.config_editor import ConfigEditor +from everviz.plugins.objectives_plot.objectives_plot import ObjectivesPlot +from everviz.plugins.objectives_plot.single_objectives_plot import SingleObjectivesPlot +from everviz.plugins.summary_plot.summary_plot import SummaryPlot from everviz.plugins.summary_plot.wells_plot import WellsPlot __all__ = [ + "BestControlsPlot", + "ConfigEditor", + "ControlsPlot", "Crossplot", "CrossplotIndexed", - "SummaryPlot", - "ObjectivesPlot", - "SingleObjectivesPlot", - "ControlsPlot", - "BestControlsPlot", "DeltaPlot", "GradientPlot", - "ConfigEditor", + "ObjectivesPlot", + "SingleObjectivesPlot", + "SummaryPlot", "WellsPlot", ] diff --git a/everviz/plugins/best_controls_plot/best_controls_plot.py b/everviz/plugins/best_controls_plot/best_controls_plot.py index e1136ad..1f20b5b 100644 --- a/everviz/plugins/best_controls_plot/best_controls_plot.py +++ b/everviz/plugins/best_controls_plot/best_controls_plot.py @@ -1,12 +1,11 @@ -from uuid import uuid4 from pathlib import Path - -from dash import html, dcc +from uuid import uuid4 import plotly.express as px +from dash import dcc, html -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.util import base64encode diff --git a/everviz/plugins/config_editor/config_editor.py b/everviz/plugins/config_editor/config_editor.py index af2e02b..3c2dbe2 100644 --- a/everviz/plugins/config_editor/config_editor.py +++ b/everviz/plugins/config_editor/config_editor.py @@ -3,10 +3,11 @@ import os from pathlib import Path from uuid import uuid4 + import yaml -from dash import callback_context +from dash import callback_context, dcc, html from dash.dependencies import Input, Output, State -from dash import html, dcc + from everviz.plugins.plugin_abc import EvervizPluginABC diff --git a/everviz/plugins/controls_plot/controls_plot.py b/everviz/plugins/controls_plot/controls_plot.py index 575ec45..cee8521 100644 --- a/everviz/plugins/controls_plot/controls_plot.py +++ b/everviz/plugins/controls_plot/controls_plot.py @@ -1,12 +1,12 @@ -from uuid import uuid4 from pathlib import Path +from uuid import uuid4 import plotly.graph_objs as go +from dash import dcc, html +from dash.dependencies import Input, Output -from dash import html, dcc -from dash.dependencies import Output, Input -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.util import base64encode diff --git a/everviz/plugins/crossplot/crossplot.py b/everviz/plugins/crossplot/crossplot.py index f14b69f..9c3b940 100644 --- a/everviz/plugins/crossplot/crossplot.py +++ b/everviz/plugins/crossplot/crossplot.py @@ -1,17 +1,16 @@ from pathlib import Path from uuid import uuid4 -from dash import html, dcc +from dash import dcc, html from dash.dependencies import Input, Output -from everviz.plugins.plugin_abc import EvervizPluginABC - -from everviz.plugins.utils.layout.sidebar_layout import get_sidebar_layout +from everviz.data.load_csv.get_data import get_data from everviz.plugins.crossplot.callback.crossplot_callback import ( crossplot_update_graph, get_graph_line, ) -from everviz.data.load_csv.get_data import get_data +from everviz.plugins.plugin_abc import EvervizPluginABC +from everviz.plugins.utils.layout.sidebar_layout import get_sidebar_layout from everviz.util import base64encode diff --git a/everviz/plugins/crossplot/crossplot_indexed.py b/everviz/plugins/crossplot/crossplot_indexed.py index 60f713a..ebd7de0 100644 --- a/everviz/plugins/crossplot/crossplot_indexed.py +++ b/everviz/plugins/crossplot/crossplot_indexed.py @@ -1,20 +1,20 @@ from pathlib import Path from uuid import uuid4 -from dash import html, dcc -from dash.dependencies import Output, Input -from everviz.plugins.plugin_abc import EvervizPluginABC +from dash import dcc, html +from dash.dependencies import Input, Output from everviz.data.load_csv.get_data import get_data from everviz.plugins.crossplot.callback.crossplot_callback import ( - get_graph_line, crossplot_update_graph, + get_graph_line, ) -from everviz.util import identify_indexed_controls, base64encode from everviz.plugins.crossplot.callback.crossplot_indexed_dropdown import ( dropdown_callback, ) +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.plugins.utils.layout.sidebar_layout import get_sidebar_layout +from everviz.util import base64encode, identify_indexed_controls class CrossplotIndexed(EvervizPluginABC): diff --git a/everviz/plugins/delta_plot/delta_plot.py b/everviz/plugins/delta_plot/delta_plot.py index c569dbe..8f1fbef 100644 --- a/everviz/plugins/delta_plot/delta_plot.py +++ b/everviz/plugins/delta_plot/delta_plot.py @@ -1,12 +1,12 @@ -from uuid import uuid4 from pathlib import Path +from uuid import uuid4 import plotly.graph_objs as go +from dash import dcc, html +from dash.dependencies import Input, Output -from dash import html, dcc -from dash.dependencies import Output, Input -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.util import base64encode diff --git a/everviz/plugins/gradient_plot.py b/everviz/plugins/gradient_plot.py index 8a2bd5a..507995f 100644 --- a/everviz/plugins/gradient_plot.py +++ b/everviz/plugins/gradient_plot.py @@ -1,17 +1,15 @@ -from uuid import uuid4 from pathlib import Path - -from pandas import IndexSlice +from uuid import uuid4 import plotly.graph_objs as go +from dash import dcc, html +from dash.dependencies import Input, Output +from pandas import IndexSlice -from dash import html, dcc -from dash.dependencies import Output, Input - -from everviz.plugins.plugin_abc import EvervizPluginABC +from everviz.components import list_select from everviz.data.load_csv.get_data import get_data +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.util import base64encode -from everviz.components import list_select class GradientPlot(EvervizPluginABC): diff --git a/everviz/plugins/objectives_plot/objectives_plot.py b/everviz/plugins/objectives_plot/objectives_plot.py index 36efc43..f32a428 100644 --- a/everviz/plugins/objectives_plot/objectives_plot.py +++ b/everviz/plugins/objectives_plot/objectives_plot.py @@ -1,14 +1,14 @@ -from uuid import uuid4 from itertools import cycle +from uuid import uuid4 import plotly.graph_objs as go +from dash import dcc, html +from dash.dependencies import Input, Output, State from plotly.colors import DEFAULT_PLOTLY_COLORS -from dash import html, dcc -from dash.dependencies import Output, Input, State -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data -from everviz.util import parse_range, get_placeholder_text, base64encode +from everviz.plugins.plugin_abc import EvervizPluginABC +from everviz.util import base64encode, get_placeholder_text, parse_range from .util import calculate_statistics diff --git a/everviz/plugins/objectives_plot/single_objectives_plot.py b/everviz/plugins/objectives_plot/single_objectives_plot.py index 8afa5ed..d8770cd 100644 --- a/everviz/plugins/objectives_plot/single_objectives_plot.py +++ b/everviz/plugins/objectives_plot/single_objectives_plot.py @@ -1,12 +1,12 @@ -from uuid import uuid4 -from pathlib import Path from itertools import cycle +from pathlib import Path +from uuid import uuid4 import plotly.graph_objs as go +from dash import dcc, html +from dash.dependencies import Input, Output from plotly.colors import DEFAULT_PLOTLY_COLORS -from dash import html, dcc -from dash.dependencies import Output, Input from everviz.data.load_csv.get_data import get_data from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.util import base64encode diff --git a/everviz/plugins/objectives_plot/util.py b/everviz/plugins/objectives_plot/util.py index 4cae22b..d7762b5 100644 --- a/everviz/plugins/objectives_plot/util.py +++ b/everviz/plugins/objectives_plot/util.py @@ -1,7 +1,7 @@ from functools import partial -import pandas as pd import numpy as np +import pandas as pd def calculate_statistics(data): diff --git a/everviz/plugins/plugin_abc.py b/everviz/plugins/plugin_abc.py index a0f6326..d930157 100644 --- a/everviz/plugins/plugin_abc.py +++ b/everviz/plugins/plugin_abc.py @@ -1,5 +1,6 @@ -from pathlib import Path import abc +from pathlib import Path + import pkg_resources from webviz_config import WebvizPluginABC from webviz_config.webviz_assets import WEBVIZ_ASSETS diff --git a/everviz/plugins/summary_plot/summary_callback.py b/everviz/plugins/summary_plot/summary_callback.py index 3270b28..de96971 100644 --- a/everviz/plugins/summary_plot/summary_callback.py +++ b/everviz/plugins/summary_plot/summary_callback.py @@ -1,6 +1,6 @@ from itertools import cycle -import plotly.graph_objs as go +import plotly.graph_objs as go from plotly.colors import DEFAULT_PLOTLY_COLORS diff --git a/everviz/plugins/summary_plot/summary_plot.py b/everviz/plugins/summary_plot/summary_plot.py index 9fbc33a..73d37f1 100644 --- a/everviz/plugins/summary_plot/summary_plot.py +++ b/everviz/plugins/summary_plot/summary_plot.py @@ -1,15 +1,14 @@ from uuid import uuid4 -from dash import html, dcc -from dash.dependencies import Output, Input, State +from dash import dcc, html +from dash.dependencies import Input, Output, State -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data -from everviz.util import parse_range, get_placeholder_text, base64encode +from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.plugins.summary_plot import summary_callback - from everviz.plugins.summary_plot.util import calculate_statistics from everviz.plugins.utils.layout.sidebar_layout import get_sidebar_layout +from everviz.util import base64encode, get_placeholder_text, parse_range class SummaryPlot(EvervizPluginABC): diff --git a/everviz/plugins/summary_plot/util.py b/everviz/plugins/summary_plot/util.py index 95ccaf8..dff38aa 100644 --- a/everviz/plugins/summary_plot/util.py +++ b/everviz/plugins/summary_plot/util.py @@ -1,7 +1,7 @@ from functools import partial -import pandas import numpy +import pandas def calculate_statistics(data, keys): diff --git a/everviz/plugins/summary_plot/wells_plot.py b/everviz/plugins/summary_plot/wells_plot.py index bf82a02..bb24d72 100644 --- a/everviz/plugins/summary_plot/wells_plot.py +++ b/everviz/plugins/summary_plot/wells_plot.py @@ -1,16 +1,14 @@ from pathlib import Path from uuid import uuid4 -from dash import html, dcc -from dash.dependencies import Output, Input +from dash import dcc, html +from dash.dependencies import Input, Output -from everviz.plugins.plugin_abc import EvervizPluginABC from everviz.data.load_csv.get_data import get_data - - +from everviz.plugins.plugin_abc import EvervizPluginABC +from everviz.plugins.summary_plot import summary_callback from everviz.plugins.summary_plot.util import calculate_statistics from everviz.plugins.utils.layout.sidebar_layout import get_sidebar_layout -from everviz.plugins.summary_plot import summary_callback from everviz.util import base64encode _WELL_RATE_KEYS = ["WOPR", "WWIR", "WGPR", "WGIR"] diff --git a/everviz/plugins/utils/layout/sidebar_layout.py b/everviz/plugins/utils/layout/sidebar_layout.py index 281cfb8..b5b30e8 100644 --- a/everviz/plugins/utils/layout/sidebar_layout.py +++ b/everviz/plugins/utils/layout/sidebar_layout.py @@ -1,5 +1,4 @@ -from dash import dcc -from dash import html +from dash import dcc, html def get_sidebar_layout(configurations): diff --git a/everviz/util.py b/everviz/util.py index a10fb20..f60cfa6 100644 --- a/everviz/util.py +++ b/everviz/util.py @@ -1,5 +1,5 @@ -import os import base64 +import os from collections import defaultdict DEFAULT_CONFIG = "everviz_webviz_config.yml" diff --git a/tests/conftest.py b/tests/conftest.py index 59458f1..2631dc5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,12 +1,12 @@ import os import sys + +import dash import pluggy import pytest -import dash +from PIL import ImageChops, ImageFilter from selenium.webdriver.common.by import By -from PIL import ImageFilter, ImageChops - # Allow everviz to be installed and have tests run without installing everest module = type(sys)("everest.plugins") module.hookimpl = pluggy.HookimplMarker("test") diff --git a/tests/integration/config_editor/test_config_editor.py b/tests/integration/config_editor/test_config_editor.py index 5fcbbd7..03a9894 100644 --- a/tests/integration/config_editor/test_config_editor.py +++ b/tests/integration/config_editor/test_config_editor.py @@ -1,8 +1,9 @@ import time + +from everviz.plugins.config_editor.config_editor import ConfigEditor from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys -from everviz.plugins.config_editor.config_editor import ConfigEditor everviz_config_1 = """title: Everest Optimization Report Test pages: diff --git a/tests/integration/crossplot/test_crossplot_indexed_integration.py b/tests/integration/crossplot/test_crossplot_indexed_integration.py index 8923a6e..7862612 100644 --- a/tests/integration/crossplot/test_crossplot_indexed_integration.py +++ b/tests/integration/crossplot/test_crossplot_indexed_integration.py @@ -1,8 +1,7 @@ -import pandas as pd -from selenium.webdriver.common.by import By - import everviz +import pandas as pd from everviz.plugins.crossplot.crossplot_indexed import CrossplotIndexed +from selenium.webdriver.common.by import By def test_crossplot_indexed_callback(app, dash_duo, monkeypatch, mocker, caplog): diff --git a/tests/integration/crossplot/test_crossplot_integration.py b/tests/integration/crossplot/test_crossplot_integration.py index 563f18c..0800963 100644 --- a/tests/integration/crossplot/test_crossplot_integration.py +++ b/tests/integration/crossplot/test_crossplot_integration.py @@ -1,5 +1,5 @@ -import pandas as pd import everviz +import pandas as pd from everviz.plugins.crossplot.crossplot import Crossplot diff --git a/tests/integration/delta_plot/test_objectives_delta_plot_integration.py b/tests/integration/delta_plot/test_objectives_delta_plot_integration.py index c57f879..0f0d9f8 100644 --- a/tests/integration/delta_plot/test_objectives_delta_plot_integration.py +++ b/tests/integration/delta_plot/test_objectives_delta_plot_integration.py @@ -1,5 +1,5 @@ -from everviz.plugins.delta_plot.delta_plot import DeltaPlot from everviz.pages.deltaplot import _get_objective_delta_values +from everviz.plugins.delta_plot.delta_plot import DeltaPlot _OBJECTIVES = [ {"batch": 0, "realization": 1, "function": "f0", "value": 100, "simulation": 1}, diff --git a/tests/integration/delta_plot/test_summary_delta_plot_integration.py b/tests/integration/delta_plot/test_summary_delta_plot_integration.py index 583a822..2a74161 100644 --- a/tests/integration/delta_plot/test_summary_delta_plot_integration.py +++ b/tests/integration/delta_plot/test_summary_delta_plot_integration.py @@ -1,9 +1,8 @@ from datetime import datetime import pandas - -from everviz.plugins.delta_plot.delta_plot import DeltaPlot from everviz.pages.deltaplot import _get_summary_delta_values +from everviz.plugins.delta_plot.delta_plot import DeltaPlot _SUMMARY = { "realization": 3 * [1] + 3 * [2] + 3 * [1] + 3 * [2], diff --git a/tests/integration/gradient_plot/test_gradient_plot_integration.py b/tests/integration/gradient_plot/test_gradient_plot_integration.py index 48e5813..1cb7da7 100644 --- a/tests/integration/gradient_plot/test_gradient_plot_integration.py +++ b/tests/integration/gradient_plot/test_gradient_plot_integration.py @@ -1,7 +1,6 @@ import pandas as pd from everviz.plugins.gradient_plot import GradientPlot - _DATA = [ {"batch": 0, "function": "f1", "control": "c1", "value": 1}, {"batch": 0, "function": "f1", "control": "c2", "value": 2}, diff --git a/tests/integration/objectives_plot/test_objectives_plot_integration.py b/tests/integration/objectives_plot/test_objectives_plot_integration.py index 6a630b7..43adbd1 100644 --- a/tests/integration/objectives_plot/test_objectives_plot_integration.py +++ b/tests/integration/objectives_plot/test_objectives_plot_integration.py @@ -1,6 +1,6 @@ import pandas as pd -from everviz.plugins.objectives_plot.objectives_plot import ObjectivesPlot from everviz.pages.objectives import _objective_values +from everviz.plugins.objectives_plot.objectives_plot import ObjectivesPlot def test_objective_plot_callback(app, dash_duo, mocker, caplog): diff --git a/tests/integration/summary_plot/test_summary_plot_integration.py b/tests/integration/summary_plot/test_summary_plot_integration.py index 1dda7ab..162b64f 100644 --- a/tests/integration/summary_plot/test_summary_plot_integration.py +++ b/tests/integration/summary_plot/test_summary_plot_integration.py @@ -1,7 +1,8 @@ from datetime import datetime + import pandas as pd -from everviz.plugins.summary_plot.summary_plot import SummaryPlot from everviz.pages.summary_values import _summary_values +from everviz.plugins.summary_plot.summary_plot import SummaryPlot def test_summary_plot_callback(app, dash_duo, mocker, caplog): diff --git a/tests/integration/summary_plot/test_well_plot_integration.py b/tests/integration/summary_plot/test_well_plot_integration.py index 67a57f1..c8d7561 100644 --- a/tests/integration/summary_plot/test_well_plot_integration.py +++ b/tests/integration/summary_plot/test_well_plot_integration.py @@ -2,9 +2,8 @@ import pandas as pd import pytest - -from everviz.plugins.summary_plot.wells_plot import WellsPlot, _get_target_keys from everviz.pages.summary_values import _summary_values +from everviz.plugins.summary_plot.wells_plot import WellsPlot, _get_target_keys def test_well_plot(app, dash_duo, mocker, caplog): diff --git a/tests/unit/crossplot/test_indexed_crossplot_layout.py b/tests/unit/crossplot/test_indexed_crossplot_layout.py index 1882fa7..429198b 100644 --- a/tests/unit/crossplot/test_indexed_crossplot_layout.py +++ b/tests/unit/crossplot/test_indexed_crossplot_layout.py @@ -1,12 +1,12 @@ import os import time -import dash -import pytest -import pandas as pd -from PIL import Image +import dash import everviz +import pandas as pd +import pytest from everviz.plugins import CrossplotIndexed +from PIL import Image def test_crossplot_layout(dash_duo, monkeypatch, mocker, tmpdir, assert_equal_images): diff --git a/tests/unit/crossplot/test_layout.py b/tests/unit/crossplot/test_layout.py index dfe4896..ec62606 100644 --- a/tests/unit/crossplot/test_layout.py +++ b/tests/unit/crossplot/test_layout.py @@ -2,19 +2,18 @@ import time import dash +import everviz +import pandas as pd import pytest from dash import html -import pandas as pd -from PIL import Image - -import everviz -from everviz.plugins import Crossplot from everviz.pages import crossplot +from everviz.plugins import Crossplot from everviz.plugins.utils.layout.sidebar_layout import ( - get_sidebar_layout, _get_dropdown, _get_radio, + get_sidebar_layout, ) +from PIL import Image @pytest.mark.parametrize("multi", [True, False]) diff --git a/tests/unit/test_control_plot_data.py b/tests/unit/test_control_plot_data.py index db5ca05..2b73f64 100644 --- a/tests/unit/test_control_plot_data.py +++ b/tests/unit/test_control_plot_data.py @@ -1,17 +1,15 @@ import os -import pytest import numpy as np import pandas as pd - -from everviz.util import get_everviz_folder +import pytest from everviz.pages.controls import ( - _control_data_per_batch, - _control_data_initial_vs_best, DataSources, + _control_data_initial_vs_best, + _control_data_per_batch, _set_up_data_sources, ) - +from everviz.util import get_everviz_folder controls = [ [ diff --git a/tests/unit/test_delta_plot_data.py b/tests/unit/test_delta_plot_data.py index 86058e5..175147a 100644 --- a/tests/unit/test_delta_plot_data.py +++ b/tests/unit/test_delta_plot_data.py @@ -2,7 +2,6 @@ from datetime import datetime import pandas - from everviz.pages.deltaplot import ( _get_objective_delta_values, _get_summary_delta_values, diff --git a/tests/unit/test_everviz_config.py b/tests/unit/test_everviz_config.py index f48fa87..4f595a7 100644 --- a/tests/unit/test_everviz_config.py +++ b/tests/unit/test_everviz_config.py @@ -1,9 +1,10 @@ import os + import everviz from everviz.config import ( - write_webviz_config, - webviz_config, setup_default_everviz_config, + webviz_config, + write_webviz_config, ) from everviz.util import DEFAULT_CONFIG diff --git a/tests/unit/test_get_indexed_control.py b/tests/unit/test_get_indexed_control.py index 7cf6b03..f399b32 100644 --- a/tests/unit/test_get_indexed_control.py +++ b/tests/unit/test_get_indexed_control.py @@ -1,5 +1,4 @@ import pytest - from everviz.util import identify_indexed_controls diff --git a/tests/unit/test_gradient_plot_data.py b/tests/unit/test_gradient_plot_data.py index 404aeb7..1d08ce0 100644 --- a/tests/unit/test_gradient_plot_data.py +++ b/tests/unit/test_gradient_plot_data.py @@ -1,15 +1,13 @@ import os -import pytest import pandas as pd - -from everviz.util import get_everviz_folder +import pytest from everviz.pages.gradientplot import ( - _gradient_values, DataSources, + _gradient_values, _set_up_data_sources, ) - +from everviz.util import get_everviz_folder _DATA = [ {"batch": 0, "function": "f1", "control": "c1", "value": 1}, diff --git a/tests/unit/test_objective_plot_data.py b/tests/unit/test_objective_plot_data.py index 147009e..b890006 100644 --- a/tests/unit/test_objective_plot_data.py +++ b/tests/unit/test_objective_plot_data.py @@ -1,16 +1,13 @@ import os -import pandas as pd -import numpy as np - import everviz - +import numpy as np +import pandas as pd from everviz.pages.objectives import ( - _set_up_data_sources, _objective_values, + _set_up_data_sources, _total_objective_values, ) - from everviz.plugins.objectives_plot.util import calculate_statistics OBJECTIVES = [ diff --git a/tests/unit/test_single_objective_plot_layout.py b/tests/unit/test_single_objective_plot_layout.py index c1bb182..5ea1aae 100644 --- a/tests/unit/test_single_objective_plot_layout.py +++ b/tests/unit/test_single_objective_plot_layout.py @@ -1,12 +1,11 @@ -import time import os -import pytest - -import pandas as pd -from PIL import Image +import time import everviz +import pandas as pd +import pytest from everviz.plugins.objectives_plot.single_objectives_plot import SingleObjectivesPlot +from PIL import Image def test_single_objective_plot_layout( diff --git a/tests/unit/test_summary_callback.py b/tests/unit/test_summary_callback.py index 4ee7d25..39a6ace 100644 --- a/tests/unit/test_summary_callback.py +++ b/tests/unit/test_summary_callback.py @@ -1,13 +1,12 @@ -from itertools import cycle from datetime import datetime +from itertools import cycle from unittest import mock -import pytest import pandas as pd -from plotly.colors import DEFAULT_PLOTLY_COLORS - +import pytest from everviz.plugins.summary_plot import summary_callback from everviz.plugins.summary_plot.util import calculate_statistics +from plotly.colors import DEFAULT_PLOTLY_COLORS __TEST_DATA = { "realization": range(12), diff --git a/tests/unit/test_summary_plot.py b/tests/unit/test_summary_plot.py index 66fceb3..49f39e0 100644 --- a/tests/unit/test_summary_plot.py +++ b/tests/unit/test_summary_plot.py @@ -1,9 +1,8 @@ from datetime import datetime -import pandas as pd import numpy as np - -from everviz.pages.summary_values import page_layout, _summary_values +import pandas as pd +from everviz.pages.summary_values import _summary_values, page_layout from everviz.plugins.summary_plot.util import calculate_statistics __TEST_DATA = { diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index 856a506..8e72045 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -1,6 +1,7 @@ import os + import pytest -from everviz.util import get_everviz_folder, parse_range, get_placeholder_text +from everviz.util import get_everviz_folder, get_placeholder_text, parse_range @pytest.fixture