Code Monkey home page Code Monkey logo

Comments (3)

cosimoNigro avatar cosimoNigro commented on July 20, 2024

Hello @pguenth,

thanks for reporting this!
I think this is the only point where I use the logging

import logging

i.e. to notify the user if sherpa and Gammapy are not installed.

Can it be that by re-importing logging here it is setting the logging back to the default level (that should be WARNING or ERROR, right)?
Perhaps adding a
logger = logging.getLogger(__name__)
and then using logger.info("...")
in fit/__init__.py will fix the issue (I think it will import the logger already defined).

from agnpy.

pguenth avatar pguenth commented on July 20, 2024

As far as I understand the logging library, this should not make a difference. Just using logging.info() and similar calls (instead of using a particular logger) should just default to some default logger. I will try to think of a test to find out.

from agnpy.

pguenth avatar pguenth commented on July 20, 2024

Okay the behavior of the logging module is apparently even more unexpected (at least to me):

The functions debug(), info(), warning(), error() and critical() will call basicConfig() automatically if no handlers are defined for the root logger.

(https://docs.python.org/3/library/logging.html#logging.basicConfig)

So the problem is most likely that agnpy's call to logging.warning() in the file you mentioned implicitely calls logging.basicConfig() with some defaults, which prevents further code (that imports agnpy) to configure the root logger.

The solution you proposed seems to be the best in my opinion (although for a slightly different reason) and is also what the documentation recommends.

from agnpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.