Skip to content

Importing nipype changes external logging configuration #2569

Closed
@jondeaton

Description

@jondeaton

Summary

If you have a python application that uses logging, importing nipype modifies your logging configuration. This results in multiple log messages being printed to the screen when you go to use the logger that you set up.

Actual behavior

Importing from nipype.interfaces.ants import N4BiasFieldCorrection reaults in log messages being printed to the console twice.

Expected behavior

When you import nipype, it should have no effect on any logging system in your application

How to replicate the behavior

import logging
from nipype.interfaces.ants import N4BiasFieldCorrection
logger = logging.getLogger('root')
logger.addHandler(logging.StreamHandler())
logger.warning("This should really only be appearing once...")

Script/Workflow details

N/a
Please put URL to code or code here (if not too long).

Platform details:

MacOS
Please paste the output of: python -c "import nipype; print(nipype.get_info()); print(nipype.__version__)"

{'pkg_path': '/Users/jonpdeaton/anaconda3/lib/python3.6/site-packages/nipype', 'commit_source': 'installation', 'commit_hash': '7d3966f', 'nipype_version': '1.0.3', 'sys_version': '3.6.4 |Anaconda custom (64-bit)| (default, Mar 12 2018, 20:05:31) \n[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]', 'sys_executable': '/Users/jonpdeaton/anaconda3/bin/python', 'sys_platform': 'darwin', 'numpy_version': '1.14.2', 'scipy_version': '0.19.1', 'networkx_version': '2.0', 'nibabel_version': '2.2.1', 'traits_version': '4.6.0'}
1.0.3

Execution environment

Anaconda, Python 3.6

Choose one

  • Container [Tag: ???]
  • My python environment inside container [Base Tag: ???]
  • My python environment outside container

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions