Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Logging from PyStell-UW #89

Open
connoramoreno opened this issue Apr 17, 2024 · 2 comments
Open

Duplicate Logging from PyStell-UW #89

connoramoreno opened this issue Apr 17, 2024 · 2 comments
Assignees

Comments

@connoramoreno
Copy link
Collaborator

connoramoreno commented Apr 17, 2024

It seems that logging to the command line is being duplicated, as exemplified below:

WARNING:root:Mayavi not found. 3D plots will not work.
14:39:56: Constructing radial build...
INFO:log:Constructing radial build...
14:39:56: Populating surface objects for in-vessel components...
INFO:log:Populating surface objects for in-vessel components...

I believe this issue is stemming from PyStell-UW since the logging format of the duplicate lines follow that specified in read_vmec.py, exemplified by the first logging output line, WARNING:root:..., which is raised in read_vmec.py. Moreover, this issue does not occur when using ParaStell functionality that does not rely on PyStell-UW (e.g., a script that only imports magnet_coils).

Poking around in read_vmec.py a bit, I think the issue is that its logging does not occur via a Logger object, but rather directly using logging function calls (e.g., logging.warning(...), logging.error(...), etc.).

If need be, I can create an issue or PR in PyStell-UW but in the interest of expediency, I'm hoping there's a solution I can implement in ParaStell instead. I haven't been able to find anything online so far.

@connoramoreno connoramoreno self-assigned this Apr 17, 2024
@connoramoreno
Copy link
Collaborator Author

connoramoreno commented Apr 17, 2024

Here's the most promising solution I could find. Unfortunately, I don't think that PyStell-UW's logging is handled by the logger manager, since it seems the logger dictionary mentioned in the article only contains logger objects, which PyStell-UW doesn't create. Here's the output from printing the logger dictionary, in case I'm missing something:

{   'PIL': <logging.PlaceHolder object at 0x7f8db6a4ce90>,
    'PIL.Image': <Logger PIL.Image (WARNING)>,
    'PIL.PngImagePlugin': <Logger PIL.PngImagePlugin (WARNING)>,
    'ezdxf': <Logger ezdxf (WARNING)>,
    'fontTools': <Logger fontTools (WARNING)>,
    'fontTools.misc': <logging.PlaceHolder object at 0x7f8da24b4c90>,
    'fontTools.misc.configTools': <Logger fontTools.misc.configTools (WARNING)>,
    'fontTools.misc.fixedTools': <Logger fontTools.misc.fixedTools (WARNING)>,
    'fontTools.misc.roundTools': <Logger fontTools.misc.roundTools (WARNING)>,
    'fontTools.ttLib': <Logger fontTools.ttLib (WARNING)>,
    'fontTools.ttLib.sfnt': <Logger fontTools.ttLib.sfnt (WARNING)>,
    'fontTools.ttLib.ttCollection': <Logger fontTools.ttLib.ttCollection (WARNING)>,
    'fontTools.ttLib.ttFont': <Logger fontTools.ttLib.ttFont (WARNING)>,
    'matplotlib': <Logger matplotlib (WARNING)>,
    'matplotlib._afm': <Logger matplotlib._afm (WARNING)>,
    'matplotlib._constrained_layout': <Logger matplotlib._constrained_layout (WARNING)>,
    'matplotlib._layoutgrid': <Logger matplotlib._layoutgrid (WARNING)>,
    'matplotlib.artist': <Logger matplotlib.artist (WARNING)>,
    'matplotlib.axes': <logging.PlaceHolder object at 0x7f8db599ec50>,
    'matplotlib.axes._axes': <Logger matplotlib.axes._axes (WARNING)>,
    'matplotlib.axes._base': <Logger matplotlib.axes._base (WARNING)>,
    'matplotlib.axis': <Logger matplotlib.axis (WARNING)>,
    'matplotlib.backend_bases': <Logger matplotlib.backend_bases (WARNING)>,
    'matplotlib.category': <Logger matplotlib.category (WARNING)>,
    'matplotlib.colorbar': <Logger matplotlib.colorbar (WARNING)>,
    'matplotlib.dates': <Logger matplotlib.dates (WARNING)>,
    'matplotlib.dviread': <Logger matplotlib.dviread (WARNING)>,
    'matplotlib.figure': <Logger matplotlib.figure (WARNING)>,
    'matplotlib.font_manager': <Logger matplotlib.font_manager (WARNING)>,
    'matplotlib.gridspec': <Logger matplotlib.gridspec (WARNING)>,
    'matplotlib.image': <Logger matplotlib.image (WARNING)>,
    'matplotlib.lines': <Logger matplotlib.lines (WARNING)>,
    'matplotlib.mathtext': <Logger matplotlib.mathtext (WARNING)>,
    'matplotlib.pyplot': <Logger matplotlib.pyplot (WARNING)>,
    'matplotlib.style': <logging.PlaceHolder object at 0x7f8db594d310>,
    'matplotlib.style.core': <Logger matplotlib.style.core (WARNING)>,
    'matplotlib.texmanager': <Logger matplotlib.texmanager (WARNING)>,
    'matplotlib.text': <Logger matplotlib.text (WARNING)>,
    'matplotlib.textpath': <Logger matplotlib.textpath (WARNING)>,
    'matplotlib.ticker': <Logger matplotlib.ticker (WARNING)>,
    'packaging': <logging.PlaceHolder object at 0x7f8db5489050>,
    'packaging.tags': <Logger packaging.tags (WARNING)>,
    'parastell': <logging.PlaceHolder object at 0x7f8da4737cd0>,
    'parastell.log': <Logger parastell.log (INFO)>,
    'pkg_resources': <logging.PlaceHolder object at 0x7f8d9e8bcf50>,
    'pkg_resources.extern': <logging.PlaceHolder object at 0x7f8d9e8bcf90>,
    'pkg_resources.extern.packaging': <logging.PlaceHolder object at 0x7f8d9e8bced0>,
    'pkg_resources.extern.packaging.tags': <Logger pkg_resources.extern.packaging.tags (WARNING)>}

@gonuke
Copy link
Member

gonuke commented Apr 20, 2024

I think it makes sense to PR into pystell_UW to introduce logger objects...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants