Skip to content

Commit 51f4b4b

Browse files
committed
Fix logger issue on paraview
1 parent bd5bbd5 commit 51f4b4b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

geos-pv/src/geos/pv/plugins/PVPythonViewConfigurator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
33
# SPDX-FileContributor: Alexandre Benedicto, Martin Lemay
44
# ruff: noqa: E402 # disable Module level import not at top of file
5-
from pathlib import Path
65
import sys
6+
from pathlib import Path
77
from typing import Any, Union, cast
88

99
import pandas as pd # type: ignore[import-untyped]

geos-pv/src/geos/pv/pythonViewUtils/Figure2DGenerator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
33
# SPDX-FileContributor: Alexandre Benedicto
4-
4+
from logging import Logger
55
from typing import Any
66

77
import pandas as pd # type: ignore[import-untyped]
8-
from geos.utils.Logger import Logger, getLogger
98
from matplotlib import axes, figure, lines # type: ignore[import-untyped]
109
from matplotlib.font_manager import ( # type: ignore[import-untyped]
1110
FontProperties, # type: ignore[import-untyped]
@@ -17,7 +16,7 @@
1716

1817
class Figure2DGenerator:
1918

20-
def __init__( self: Self, dataframe: pd.DataFrame, userChoices: dict[ str, list[ str ] ] ) -> None:
19+
def __init__( self: Self, dataframe: pd.DataFrame, userChoices: dict[ str, list[ str ] ], logger: Logger ) -> None:
2120
"""Utility to create cross plots using Python View.
2221
2322
We want to plot f(X) = Y where in this class,
@@ -26,14 +25,15 @@ def __init__( self: Self, dataframe: pd.DataFrame, userChoices: dict[ str, list[
2625
Args:
2726
dataframe (pd.DataFrame): data to plot
2827
userChoices (dict[str, list[str]]): user choices.
28+
logger (Logger): Logger to use.
2929
"""
3030
self.m_dataframe: pd.DataFrame = dataframe
3131
self.m_userChoices: dict[ str, Any ] = userChoices
3232
self.m_fig: figure.Figure
3333
self.m_axes: list[ axes._axes.Axes ] = []
3434
self.m_lines: list[ lines.Line2D ] = []
3535
self.m_labels: list[ str ] = []
36-
self.m_logger: Logger = getLogger( "Python View Configurator" )
36+
self.m_logger: Logger = logger
3737

3838
try:
3939
# apply minus 1 multiplication on certain columns

geos-pv/src/geos/pv/pythonViewUtils/mainPythonView.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
# SPDX-FileContributor: Alexandre Benedicto
44
# type: ignore
55
# ruff: noqa
6+
from logging import Logger, getLogger, INFO
7+
from paraview.detail.loghandler import ( # type: ignore[import-not-found]
8+
VTKHandler,
9+
) # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/detail/loghandler.py
10+
11+
logger: Logger = getLogger( "Python View Configurator" )
12+
logger.setLevel( INFO )
13+
vtkHandler: VTKHandler = VTKHandler()
14+
logger.addHandler( vtkHandler )
15+
616
try:
717
import matplotlib.pyplot as plt
818
from paraview import python_view
@@ -20,7 +30,7 @@
2030
variableName # noqa: F821
2131
)
2232
dataframe = pvt.mergeDataframes( dataframes, variableName ) # noqa: F821
23-
obj_figure = Figure2DGenerator( dataframe, userChoices ) # noqa: F821
33+
obj_figure = Figure2DGenerator( dataframe, userChoices, logger ) # noqa: F821
2434
fig = obj_figure.getFigure()
2535

2636
def setup_data( view ) -> None: # noqa
@@ -32,7 +42,4 @@ def render( view, width: int, height: int ): # noqa
3242
return imageToReturn
3343

3444
except Exception as e:
35-
from geos.utils.Logger import getLogger
36-
37-
logger = getLogger( "Python View Configurator" )
38-
logger.critical( e, exc_info=True )
45+
logger.critical( e, exc_info=True )

0 commit comments

Comments
 (0)